copy script berikut dan simpan dengan nama kalkulator.html
<html>
<head>
<title>Kalkulator HTML Sederhana Dengan Javascript</title>
<SCRIPT LANGUAGE="JavaScript">
window.defaultStatus="Let count your number"
function tambah()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.hasil.value = c
}
function kurang()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.hasil.value=c
}
function kali()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.hasil.value=c
}
function bagi()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.hasil.value = c
}
function pangkat()
{
a=eval(form.a.value)
b=eval(form.b.value)
c=Math.pow(a, b)
form.hasil.value = c
}
function akar()
{
a=eval(form.a.value)
c=Math.sqrt(a)
form.hasil.value = c
form.b.value = "Akar pangkat 2"
}
function kosong()
{
form.a.focus()
form.a.value=""
form.b.value=""
form.hasil.value=""
}
</SCRIPT>
<style type="text/css">
<!--
#Header {
position:absolute;
left:410px;
top:4px;
width:455px;
height:76px;
z-index:1;
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
text-align: center;
color: #006;
font-weight: bold;
}
#font_Header {
font-size: 24px;
}
#Nama {
position:absolute;
left:493px;
top:231px;
width:250px;
height:107px;
z-index:2;
color: #006;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
-->
</style>
</head>
<body onload=kosong()>
<div id="Header">
<p>Kalkulator HTML Sederhana Dengan Javascript</p>
</div>
<div id="Nama">
</div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<FORM name="form">
<table width="1087" height="45" class="kalkulator" >
<tr>
<td width="236" height="39" valign="top"><p>Angka 1
<input type="text" name="a">
</p></td>
<td width="236" valign="top">Angka 2
<input type="text" name="b"></td>
<td width="315" valign="top"><input type="button" value="Hapus" onClick="kosong()">
<input type="button" value="+" onClick="tambah()">
<input type="button" value="-" onClick="kurang()">
<input type="button" value="x" onClick="kali()">
<input type="button" value="/" onClick="bagi()">
<input type="button" value="^" onClick="pangkat()">
<input type="button" value="Akar" onClick="akar()"></td>
<td width="280" valign="top">Hasil =
<input type "text" name="hasil" disabled="true"></td>
</tr>
</table>
</FORM>
</body>
</html>
Selamat Belajar.........
0 Response to "membuat kalkulator dengan html dan java, Bukan dengan PHP"
Post a Comment