OwnZ! StyLe
  Script Örnekleri 1
 
Function & Document

(document.frm.ad.value=="fatma") = = karşılaştırma yapmak için kullanılır. = değer atamak için kullanılır.

document.write(document.frm.ad.value+" "+document.frm.x.value+"li");
document.write("bu kişiyi tanımıyoruz");
Ekrana yazdırmak için kullanlır.

frm -> form'a verdiğimiz isimdir.
ad -> eklediğimiz text kutusunun adıdır.


<html>
<head>
<script>
function grt()
{
if(document.frm.ad.value=="fatma") document.write(document.frm.ad.value+" "+document.frm.x.value+"li");
else
document.write("bu kişiyi tanımıyoruz");
}
</script>
</head>
<body>
<form name="frm">
Adınız:<input type="text" name="ad"><br>
<select name="x">
<optgroup label="İç Anadolu">
<option value="antalya">antalya</option>
<option value="ordu">ordu</option>
<option value="yozgat">yozgat</option>
</optgroup>
<optgroup label="Ege">
<option value="izmir">izmir</option>
<option value="istanbul">istanbul</option>
<option value="ankara">ankara</option>
</optgroup>
</select>
</form>
<button onclick="grt()">Görüntüle</button>
</body>
</html>
 



İki Sayının Çarpımını Bulma


var x=parseInt(document.fr.x1.value); -> x1 isimli text kutusuna girilen sayıyı string'e çevirir.
y=parseInt(document.fr.y1.value); ->y1 isimli text kutusuna girilen sayıyı string'e çevirir.
alert(x*y); ->sonucu gösterir.
<html>
<head>
<script>
function grt()
{
var x=parseInt(document.fr.x1.value);
y=parseInt(document.fr.y1.value);
alert(x*y);
}
</script>
</head>
<body>
<form name="fr">
<input type="text" name="x1"><br>
<input type="text" name="y1"><br>
<input type="button" name="b1" value=sonuç onclick="grt()">
</body>
</html>
 


ÜST ALMA

var s1=parseInt(document.frm.sayi1.value);
var s2=parseInt(document.frm.sayi2.value);
parseInt girileni string'e çevirir.

<html>
<head>
<title>fatmayıldız</title>
<script>
function us()
{
var t=1;
var s1=parseInt(document.frm.sayi1.value);
var s2=parseInt(document.frm.sayi2.value);
for(i=1; i<=s2; i++)
t=t*s1;
document.frm.sonuc.value=t;
}
</script>
</head>
<body>
<form name="frm">
sayı gir<input type="text" name="sayi1"><br>
us gir<input type="text" name="sayi2"><br>
sonuc<input type="text" name="sonuc"><br>
<input type="button" name="v1" value="TIKLA" onclick="us()"><br>
</form>
</body>
</html>
 



Dört İşlem

<html>
<head>
<script>
function islem(txt)
{
x=parseInt(document.form.sayi1.value);
y=parseInt(document.form.sayi2.value);
switch(txt)
{
case '+':document.form.den.value=x+y;break;
case '-':document.form.den.value=x-y;break;
case '*':document.form.den.value=x*y;break;
case '/':document.form.den.value=x/y;break;
}
}
</script>
</head>
<body bgcolor="purple">
<form name="form">
<table border="0" align="center">
<tr>
<td>1.sayi</td>
<td><input type="text" name="sayi1" ></td>
<td rowspan=3 align="center" width="150">
<input type="text" name="den" rows=3 cols=8></td>
</tr>
<tr>
<td>2.sayı</td>
<td><input type="text" name="sayi2"></td>
</tr>
<tr>
<td align="center" colspan=2>
<input type="button" onclick="islem('+')" value="+++++">
<input type="button" onclick="islem('-')" value="-----">
<input type="button" onclick="islem('*')" value="*****">
<input type="button" onclick="islem('/')" value="/////"></td>
</tr>
</form>
</table>
</body>
</html>
   


 
  19 ziyaretçi bugün sitemizi ziyaret etti! ( kişi Çevrimiçi )  
 
Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol