membuat kalkulator sederhana menggunakan HTML



<html>
<head>
<title>Kalkulator Online</title>
<script>
function hitung(angka1,angka2,operator)
{
var hasil;
if (operator==”tambah”){
hasil = parseInt(angka1) + parseInt(angka2);
}else if(operator==”kurang”){
hasil = parseInt(angka1) – parseInt(angka2);
}else if(operator==”kali”){
hasil = parseInt(angka1) * parseInt(angka2);
}else if(operator==”bagi”){
hasil = parseInt(angka1) / parseInt(angka2);
}
document.getElementById(“hasil”).innerHTML = “<b>” +hasil+ “</b>”;
return false;
}
</script>
</head>
<body>
<form name=”form1″ method=”post” action=”hitung.php” onsubmit=”return hitung
(form1.angka.value,form1.angka2.value,form1.operator.value);”>
<table align=”center” width=”28%” border=”5″ bgcolor=”lime”>
<tr>
<td align=”center”>
<h1><center><u>Online Calculator</u></center></h1>
<h3>
Bilangan 1<input name=”angka” type=”text” id=”angka”><br>
<center><select name=”operator” id=”operator”>
<option value=”tambah”>+</option>
<option value=”kurang”>-</option>
<option value=”kali”>*</option>
<option value=”bagi”>/</option>
</select></center>Bilangan 2<input name=”angka2″ type=”text” id=”angka2″><br>
<center><input type=”submit” name=”Submit” value=”Hitung”></center><div style=”float:left;”>- Hasil :</div><br>
<div id=”hasil”></div>
</h3>
<marquee><h6>Kalkulator Online dengan operator Aritmatika</h6></marquee>
</td>
</tr>
</table>
</form>
</body>
</html>

berikut adalah hasil nya…

Kalkulator Online

Iklan

tulis comment nya...

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s