SCIPRT :
<!DOCTYPE HTML>
<html lang="en">
<head>
<title><H1>Kalkulator Tugas Praktikum></H1></title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
function kalkulator(){
var myForm = document.form1;
var a=eval(myForm.a.value);
var b=eval(myForm.b.value);
var pil= myForm.opt.value;
if (pil == "penjumlahan") {
var c = a + b;
}else if (pil == "pengurangan") {
var c = a - b;
} else if (pil == "perkalian") {
var c = a * b;
} else if (pil == "pembagian") {
var c = a / b;
}
myForm.total.value = c;
}
function resetForm(){
document.form1.reset();
}
//-->
</script>
<center>
<font size= ”5"> Kalkulator Tugas Praktikum </font>
<br>
<br>
<form name="form1" action="#">
<input type="text" name="a" />
<select name="opt">
<option value="penjumlahan"> + </option>
<option value="pengurangan"> - </option>
<option value="perkalian"> * </option>
<option value="pembagian"> / </option>
</select>
<input type="text" name="b" />
<input type="button" value="=" onClick="kalkulator()" />
<input type="text" name="total" disabled="true" /> <br/>
<p>
<input type="button" value="CLEAR" onClick="resetForm()" />
</form>
</body>
</html>
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar