Rabu, 10 Oktober 2012

Kalkulator sederhana menggunakan HTML dan Java Script


silahkan dicopy.. :)) semoga bermanfaat.. 

<html>
<head>
<title>Kalkulator Sederhana</title>
<SCRIPT LANGUAGE="JavaScript">
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
}


</SCRIPT>
<style type="text/css">
<!--
.style1 {
color: #993366;
font-style: italic;
}
-->
</style>
</head>

<body>
<h2 align="center" class="style1"> <blink> Program Kalkulator </blink> </h2>
<FORM name="form">
<table border="1" align="center">
<tr>
<td width="234" height="170" valign="top" bgcolor="#99FF99"><p>Angka 1
            <input type="text" name="a">  
          <br>
Angka 2
<input type="text" name="b">
<br>
<br>
<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 name="Hapus" type="reset" id="Hapus" value="Hapus">
</label>
<br>
<br>
<b>Hasil</b> <input type "text" name="hasil">
      </td>
</tr>
</table>
</FORM>
</body>
</html>

Tidak ada komentar:

Posting Komentar