<html>
<head>
<body bgcolor="pink">
</head>
<script language="JavaScript" type="text/javascript">
function hitung(){
var myForm =
document.form1;
var x=eval
(myForm.x.value);
var y=eval
(myForm.y.value);
var pil=
myForm.opt.value;
if (pil == "tambah") {
var z = x+y;
} else if (pil == "kurang") {
var z = x-y;
} else if (pil == "kali") {
var z = x*y;
} else if (pil == "bagi") {
var z = x/y;
}
myForm.hasil.value = z;
myForm.x.value = "" ;
myForm.y.value = "" ;
}
function resetForm(){
document.form1.reset();
}
</script>
<br><br><br>
<table width="400" border="10" class="badan" align="center">
<tr>
<td bgcolor="cyan">
<br>
<center><h1>Kalkulator</h1></center>
<br>
<div align="center" class="content_li">
<form name="form1" action="#">
<p>Bilangan 1 <input type="text" name="x" /> </p>
<p>Bilangan 2 <input type="text" name="y" /> </p>
<p>Hasil <input type="text" name="hasil" /></p>
<br>
<p>Operasi Hitung:
<select name="opt"></p>
<option value="tambah"> Penjumlahan</option>
<option value="kurang"> Pengurangan</option>
<option value="kali"> Perkalian</option>
<option value="bagi"> Pembagian </option>
</select>
<input type="button" value="=" onclick="hitung()" />
<input type="button" value="Ulang" onclick="resetForm()" />
<br><br><br>
</form>
</td>
</table>
</body>
</html>
<head>
<body bgcolor="pink">
</head>
<script language="JavaScript" type="text/javascript">
function hitung(){
var myForm =
document.form1;
var x=eval
(myForm.x.value);
var y=eval
(myForm.y.value);
var pil=
myForm.opt.value;
if (pil == "tambah") {
var z = x+y;
} else if (pil == "kurang") {
var z = x-y;
} else if (pil == "kali") {
var z = x*y;
} else if (pil == "bagi") {
var z = x/y;
}
myForm.hasil.value = z;
myForm.x.value = "" ;
myForm.y.value = "" ;
}
function resetForm(){
document.form1.reset();
}
</script>
<br><br><br>
<table width="400" border="10" class="badan" align="center">
<tr>
<td bgcolor="cyan">
<br>
<center><h1>Kalkulator</h1></center>
<br>
<div align="center" class="content_li">
<form name="form1" action="#">
<p>Bilangan 1 <input type="text" name="x" /> </p>
<p>Bilangan 2 <input type="text" name="y" /> </p>
<p>Hasil <input type="text" name="hasil" /></p>
<br>
<p>Operasi Hitung:
<select name="opt"></p>
<option value="tambah"> Penjumlahan</option>
<option value="kurang"> Pengurangan</option>
<option value="kali"> Perkalian</option>
<option value="bagi"> Pembagian </option>
</select>
<input type="button" value="=" onclick="hitung()" />
<input type="button" value="Ulang" onclick="resetForm()" />
<br><br><br>
</form>
</td>
</table>
</body>
</html>
Tidak ada komentar:
Posting Komentar