This is a simple calculator program written in JavaScript:
Simple Calculator
Exit Calculator!!
<script language=javascript>
var Novalue = 0;
function disp(element) {
if (Novalue == 1) {
document.form1.txtres.value = "";
Novalue = 0;
}
document.form1.txtres.value=document.form1.txtres.value+element.value;
}
function calc() {
document.form1.txtres.value = eval(document.form1.txtres.value);
Novalue = 1;
}
function clearall() {
document.form1.txtres.value = "";
}
</script>
</head>
<body>
<center>
<a href="" onMouseOver="if(confirm('Are you sure you want to exit!!')) { exit();};return true;">Exit Calculator!!</a>
<form name="form1">
<table width="204" height="168" border="1" cellpadding="3" cellspacing="3">
<tr>
<td colspan="6"><center><input type="text" name="txtres" readonly="no" width="190"></center></td>
</tr>
<tr>
<td width="28" height="29"><input type=button value=1 name=cmd1 onclick=disp(this.form.cmd1)></td>
<td width="28"><input type=button name=cmd2 value=2 onClick=disp(this.form.cmd2)></td>
<td width="28"><input type="button" name="cmd3" value="3" onClick="disp(this.form.cmd3)"></td>
<td width="25"><input type=button value=* name=cmdmul onclick=disp(this.form.cmdmul)></td>
<td width="37" colspan="2"><input type=button value=+ name=cmdplus onClick=disp(this.form.cmdplus)></td>
</tr>
<tr>
<td><input type="button" name="cmd4" value="4" onClick="disp(this.form.cmd4)"></td>
<td><input type="button" name="cmd5" value="5" onClick="disp(this.form.cmd5)"></td>
<td><input type="button" name="cmd6" value="6" onClick="disp(this.form.cmd6)"></td>
<td><input type=button value=/ name=cmddiv onclick=disp(this.form.cmddiv)></td>
<td width="37" colspan="2"><input type=button value=- name=cmdminus onclick=disp(this.form.cmdminus)></td>
</tr>
<tr>
<td><input type="button" name="cmd7" value="7" onClick="disp(this.form.cmd7)"></td>
<td><input type="button" name="cmd8" value="8" onClick="disp(this.form.cmd8)"></td>
<td><input type="button" name="cmd9" value="9" onClick="disp(this.form.cmd9)"></td>
<td><input type="button" name="eq" value="=" onClick="calc()"></td>
<td width="37" colspan="2"><input type=button value=Clr name=cmdclear onClick=clearall()></td>
</tr>
<tr>
<td colspan="6"><center><font face="Courier New, Courier, monospace" size="-1"> 2009 © to Rajan</font></center></td>
</tr>
</table>
<br>
</form>
</center>
</body>
</html>