9 Eylül 2021 Perşembe

Javascript Hesap Makinesi

 <html>

<head>

<title> başlık </title>

<script type="text/javascript">

function topla()

{

x=document.getElementById("txt1").value;

y=document.getElementById("txt2").value;

toplam=x+y;

alert(toplam);

}

function cikar()

{

x=document.getElementById("txt1").value;

y=document.getElementById("txt2").value;

fark=x-y;

alert(fark);

}

function carp()

{

x=document.getElementById("txt1").value;

y=document.getElementById("txt2").value;

carpim=x*y;

alert(carpim);

}

function bol()

{

x=document.getElementById("txt1").value;

y=document.getElementById("txt2").value;

bolum=x/y;

alert(bolum);

}

</script>

</head>

<body>

<table border=1 cellpadding=10>

<tr>

<td>1.sayi :</td><td><input type="text" id="txt1"/></td>

</tr>

<tr>

<td>2.sayi:</td><td><input type="text" id="txt2"/></td>

</tr>

<tr>

<td>islemler</td>

<td>

<input type="button" value="TOPLA" onclick="topla()"/>

<input type="button" value="ÇIKAR" onclick="cikar()"/>

<input type="button" value="ÇARP" onclick="carp()"/>

<input type="button" value="BÖL" onclick="bol()"/>

</td>

</tr>

</table>

</body>


</html>


Javascript Parametre Kullanımı

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

function topla(x,y)

{

var toplam=x+y;

alert("TOPLAM="+toplam);

}

</script>

</head>

<body>

<input type="button" value="TIKLA" onclick="topla(5,6)">

</body>

</html>


Javascript Birden Fazla Fonksiyon

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

function f1()

{

alert("fonksiyon 1");

}

function f2()

{

alert("fonksiyon 2");

}

</script>

</head>

<body>

<input type="button" value="TIKLA" onclick="f1();f2()">

</body>

</html>


Javascript Fonksiyonlarda Döngü

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

function dongu()

{

document.write("<h2>fonksiyon içinde döngü kullanıyoruz</h2><p/>");

for(i=1;i<=10;i++)

{

document.write(i+"<br/>");

}

document.write("<p/>döngü bitti..");

}

</script>

</head>

<body>

<input type="button" value="TIKLA" onclick="dongu()">

</body>

</html>


Javascript Fonksiyonları Çağırmak

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

function mesaj_gonder()

{

alert("Bu mesaj fonksiyondan gelmektedir");

}

</script>

</head>

<body>

<input type="button" value="TIKLA" onclick="mesaj_gonder()">

</body>

</html>


8 Eylül 2021 Çarşamba

Javascript While Döngüsü

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

var x=1;

while(x<10)

{

document.write("Ege Üniversitesi <br/>");

x++;

}

</script>

</html>


Javascript For In Döngüsü

 <html>

<head>

<title> başlık </title>

</head>

<script type="text/javascript">

var x;

var dizi=new Array();

dizi[0]="C#";

dizi[1]="Sql Server";

dizi[2]="Asp.Net";

dizi[3]="Ado.Net";

dizi[4]="HTML";

dizi[5]="CSS";

dizi[6]="Javascript";

dizi[7]="PHP";

dizi[8]="ASP";

for(x in dizi)

{

document.write(dizi[x]);

document.write("<br/>");

}

</script>

</html>