Oleh: leonard260788 | November 20, 2008

Web programming

<html>
<head>
<title>No more one</title>
<script language=”javascript”>
function hitung(){

//alert(“denis leonard”);
var a = window.document.getElementsByName(“a”);
var op = window.document.getElementsByName(“op”);
var b = window.document.getElementsByName(“b”);

var x = parseInt(a[0].value);
var y = parseInt(b[0].value);

var hasil;

switch(op[0].value){
case “0″ : hasil = x + y;break;
case “1″ : hasil = x – y;break;
case “2″ : hasil = x * y;break;
case “3″ : hasil = x / y;break;

}

var z = window.document.getElementsByName(“hasil”);

z[0].value = hasil;

}
</script>

</head>
<body>
<input type = “text” name =”a”>
<select name = “op”>
<option value = “0″> + </option>
<option value = “1″> – </option>
<option value = “2″> * </option>
<option value = “3″> / </option>
</select>
<input type = “text” name = “b”>
<input type = “button” value=”=” name = “c” onClick=”hitung();”>
<input type = “text” name = “hasil”>
</body>

<!– dibuat oleh denis leonard–>

</html>

Download source code lengkap : http://www.kitaupload.com/download.php?file=863javascript.html


Tanggapan

  1. beuh… dari siang gw cariin ni code..

    bikin2 cuma bisa jalan diIE duank>.<

    thanks bos…

    numpang sedot codenya.


Beri tanggapan

Your response:

Kategori