Monday, 3 September 2018

Contoh Script membuat kalkulator dengan html

<html>
<head>
<title>AuliyaRahmah_Contoh program JavaScript</title>
<style type="text/css">
</style>
<SCRIPT LANGUAGE="JavaScript">
window.defaultStatus="Let count your number"

function tambah()
{
bil1=eval(form.bil1.value)


bil2=eval(form.bil2.value) hsl=bil1+bil2 form.hasil.value = hsl
}

function kurang()
{ bil1=eval(form.bil1.value) bil2=eval(form.bil2.value) hsl=bil1-bil2 form.hasil.value=hsl
}

function kali()
{ bil1=eval(form.bil1.value) bil2=eval(form.bil2.value) hsl=bil1*bil2 form.hasil.value=hsl
}

function bagi()
{ bil1=eval(form.bil1.value) bil2=eval(form.bil2.value) hsl=bil1/bil2 form.hasil.value = hsl
}

</SCRIPT>
</head>

<body>
<font>Program Kalkulator Auliya Rahmah</font></br>
<FORM name="form">
<table class="kalkulator">
<tr>
<td valign="top">
<p>Bilangan 1 <input type="text" name="bil1"></p>
<p>Bilangan 2 <input type="text" name="bil2"></p>
<p>
<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()">
</p>
<p>Hasil<input type "text" name="hasil" disabled="true"></p>
</td>




</tr>
</table>
</FORM>
</body>
</html>

<td>&nbsp;</td>



Download disini

No comments:

Post a Comment