Bagaimana Cara Membuat Calculator Menggunakan file Html
pertama sobat jalankan Aplikasi notepad di window sobat
kedua copy Code htmlnya
ini Code nya Html nya
<html>
<head>
<title>Kalkulator</title>
<script LANGUAGE="JavaScript">
function tambah (input, character){
if (input.value==null||input.value=='0')
input.value=character
else
input.value+=character
}
function ubah_tanda(input){
if(input.value.substring(0,1)=="-")
input.value=input.value.substring(1,input.value.length)
else
input.value+="-"+input.value
}
function hitung(form){
form.display.value=eval(form.display.value)
}
</script>
</head>
<body>
<h1 align=center>Kalkulator</h1>
<form>
<table border="3" align=center cellpadding="5" cellspacing="5">
<tr>
<td colspan="4" align=center><input type="text" name="display" value="" size=20></td>
</tr>
<tr>
<td><input type="button" value="7" onClick="tambah(this.form.display, '7')"></td>
<td><input type="button" value="8" onClick="tambah(this.form.display, '8')"></td>
<td><input type="button" value="9" onClick="tambah(this.form.display, '9')"></td>
<td><input type="button" value="/" onClick="tambah(this.form.display, '/')"></td>
</tr>
<tr>
<td><input type="button" value="4" onClick="tambah(this.form.display, '4')"></td>
<td><input type="button" value="5" onClick="tambah(this.form.display, '5')"></td>
<td><input type="button" value="6" onClick="tambah(this.form.display, '6')"></td>
<td><input type="button" value="*" onClick="tambah(this.form.display, '*')"></td>
</tr>
<tr>
<td><input type="button" value="1" onClick="tambah(this.form.display, '1')"></td>
<td><input type="button" value="2" onClick="tambah(this.form.display, '2')"></td>
<td><input type="button" value="3" onClick="tambah(this.form.display, '3')"></td>
<td><input type="button" value="-" onClick="tambah(this.form.display, '-')"></td>
</tr>
<tr>
<td><input type="button" value="C"onClick="tambah(this.form.display.value=0, 'clear')"></td>
<td><input type="button" value="0" onClick="tambah(this.form.display, '0')"></td>
<td><input type="button" value="." onClick="tambah(this.form.display, '.')"></td>
<td><input type="button" value="+" onClick="tambah(this.form.display, '+')"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value=" CE " onClick="tambah(this.form.display.value=0, 'clear')"></td>
<td colspan="2"><input type="button" value=" = " name="Enter" onClick="hitung(this.form)"></td>
</tr>
</table>
</form>
</body>
</html
pastekan didalam notepad
lalu save As
pilh All file
encoding rubah utf-8
tulis file Calculator.html
dag bgtu aja
selamat mencoba