Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Kalkulator</title>
- <script language="JavaScript" type="text/javascript">
- <!--
- function hitung(){
- var myForm = document.form1;
- 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.form1.reset();
- }
- //-->
- </script>
- </head>
- <body>
- <form name="form1" action="#">
- <input type="text" name="x" />
- <select name="opt">
- <option value="tambah"> + </option>
- <option value="kurang"> - </option>
- <option value="kali"> * </option>
- <option value="bagi"> / </option>
- </select>
- <input type="text" name="y" />
- <input type="button" value="=" onClick="hitung()" />
- <input type="text" name="hasil" disabled="true" /><br/>
- <input type="button" value="CLEAR" onClick="resetForm()" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement