Modul 5
STUDI KASUS
<!DOCTYPE html>
<html lang="en">
<head>
<title>kalkulator sederhana</title>
</head>
<body>
<p>Kalkulator Sederhana dengan JavaScript
<script language="JavaScript" type="text/javascript">
<!--
function tambah() {
var a = eval (document.form1.a.value)
var b = eval (document.form1.b.value)
c = a+b
document.form1.hasil.value = +c
}
function kurang() {
var a = eval (document.form1.a.value)
var b = eval (document.form1.b.value)
var c = a-b
document.form1.hasil.value = +c
}
function kali() {
var a = eval (document.form1.a.value)
var b = eval (document.form1.b.value)
var c = a*b
document.form1.hasil.value = c
}
function bagi() {
var a = eval (document.form1.a.value)
var b = eval (document.form1.b.value)
var c = a/b
document.form1.hasil.value = c
}
function hapus () {
document.form1.reset();
}
-->
</script>
<form name=form1 action="#">
<p>Bilangan 1 :
<input type="text" name="a" />
<p>Bilangan 2 :
<input type="text" name="b" />
<p>
<input type="button" value=" + " onclick="tambah()" />
<input type="button" value=" - " onclick="kurang()" />
<input type="button" value=" * " onclick="kali()" />
<input type="button" value=" / " onclick="bagi()" />
<p>Hasil :
<input type="text" name="hasil" disabled="true" />
<p>Bersihkan :
<input type="button" value=" Clear " onclick="hapus()" />
</form>
<p> ©
<a href="http://www.facebook.com/angga conello">angga achmad c</a>
</body>
</html>
06.59 |
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar