Sketchware - Kalkulator html/js

Guide HERE!


Code html :
data:text/html,<html>
<head>
<title>Kalkulator Sederhana</title>
</head>
<style type="text/css">
body{
margin: 0 auto;
}
.konten{
margin: 8px;
font-size:60px;
}
.inpme{
padding: 5px;
}
</style>
<body>
<script language="JavaScript" type="text/javascript">
function hitung(){

var myForm = document.formcalc;
var x=eval(myForm.x.value);
var y=eval(myForm.y.value);
var pil= myForm.opt.value;
if (pil == "tambah") {
var z = x + y;
  } else if (pil == "kurang") {
var z = x - y;
} else if (pil == "kali") {
var z = x * y;
  } else if (pil == "bagi") {
var z = x / y;
}
  myForm.hasil.value = z;
myForm.x.value = "";
  myForm.y.value = "";
}
function resetForm(){
document.formcalc.reset();
}
</script>
<div align="center" class="konten">
<form name="formcalc" action="#">
<table>
<tr>
<td>Bilangan 1</td>
<td>:</td>
<td><input class="inpme" type="number" name="x" placeholder="Masukan angka 1,2,3,4..." /></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<select class="inpme" style="background:red;color:white;" name="opt">
<option value="tambah"> + (tambah)</option>
<option value="kurang"> - (kurang)</option>
<option value="kali"> * (kali)</option>
<option value="bagi"> / (bagi)</option>
</select>
</td>
</tr>
<tr>
<td>Bilangan 2</td>
<td>:</td>
<td><input class="inpme" type="number" name="y" placeholder="Masukan angka 1,2,3,4..." /></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input style="font-size:20px;" type="button" value="=" onClick="hitung()" />
</td>
</tr>
<tr>
<td>Hasil</td>
<td>:</td>
<td><input style="background:transparent;padding:5px;" type="text" name="hasil" disabled="true" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input class="inpme" type="button" value="CLEAR" onClick="resetForm()" />
</td>
</tr>
</table>
</form>
</div>
<!---------------------------
|      CREDITS IYORTML      |
---------------------------->
</body>
</html>

Komentar

Postingan populer dari blog ini

Instagram Followers Free

Sketchware Tutorial - Spinner

Me Movie