Senin, 04 Juni 2012

Anwari

JAVA SCRIPT : Membuat Kalkulator 2


JAVA SCRIPT : Kalkulator 2

<html>
<head>
<title>anwari-kyu1</title>
<meta name="Programmer" content="Muhammad Anwari" />
<script language="javascript" type="text/javascript">
<!--
  var flag = false;
  function isi(num) {
    if (flag) calc.b.value += num;
    else calc.a.value += num;
  }
  function tambah()
  {
    calc.opr.value = ' + '
    flag = true;
    calc.b.focus()
  }
  function kurang()
  {
    calc.opr.value = ' - '
    flag = true;
    calc.b.focus()
  }
  function kosong()
  {
    calc.a.focus()
    calc.a.value=""
    calc.opr.value=""
    calc.b.value=""
    calc.c.value=""
    flag = false;
  }
//-->
</script>
<style type="text/css">
p {
  line-height:1.3em;
  color:#00CC00
}
</style>
</head>
<body bgcolor="#000000">
<body onload=kosong()>
<center>
<p style="padding:20px 0px 30px 0px"><font size="6">JavaScript Calculator</font></p>
<form name="calc">
  <table border="2" bordercolor="#CCFF33">
    <tr>
      <td>
      <input type="text" name="a" size="2" />
      <input type="text" name="opr" size="1" />
      <input type="text" name="b" size="2" /> =
      <input type="text" name="c" size="2" />
      <br/>
      </td>
    </tr>
    <tr>
      <td>
      <input type="button" name="one"   value="  1  " onClick="isi(1)" />
      <input type="button" name="two"   value="  2  " onClick="isi(2)" />
      <input type="button" name="three" value="  3  " onClick="isi(3)" />
      <input type="button" name="plus"  value="  +  " onClick="tambah()" />
      <br/>
      <input type="button" name="four"  value="  4  " onClick="isi(4)" />
      <input type="button" name="five"  value="  5  " onClick="isi(5)" />
      <input type="button" name="six"   value="  6  " onClick="isi(6)" />
      <input type="button" name="minus" value="  -  " onClick="kurang()" />
      <br/>
      <input type="button" name="seven" value="  7  " onClick="isi(7)" />
      <input type="button" name="eight" value="  8  " onClick="isi(8)" />
      <input type="button" name="nine"  value="  9  " onClick="isi(9)" />
      <br/>
      <input type="button" name="clear" value="  c  " onClick="kosong()" />
      <input type="button" name="zero"  value="  0  " onClick="isi(0)" />
      <input type="button" name="DoIt"  value="  =  " onClick="calc.c.value=eval(calc.a.value+calc.opr.value+calc.b.value)" />
      <br/>
      </td>
    </tr>
  </table>
</form>
<font face="pristina"size="7"color="#00FF00">
<p>Created by : <br/>Muhammad Anwari<br>STM Muhammadiyah Tasikmalaya</p><hr/></font>
<font face="rockwell"size="4"color="#00FF00">
<p>Kampung Situbeet Mangkubumi</p></font>
</center>
</body>
</html>

Save dengan nama kalkulator.html
Maka akan tampil gambar dibawah ini 


0 Komentar:

Posting Komentar