Hi,
I'm trying to bulid a working (simplified) calculator using JavaScript and have got stuck. Unfortunately I'm on a time limit so any help would be appreciated. I've got this far:
<html>
<head>
<title>Calculator</title>
<script language="javascript">
var input = "";
function buttonstore(value) {
input += value;
document.Calculator.txtAns.value = input;
}
</script>
</head>
<body>
<form name="Calculator" action="">
<table border="2" width="250" bgcolor="#003366">
<tr>
<td colspan="4" width="240" height="40" align="center" valign="center"><input type="text" value="0" name="txtAns"></td>
</tr>
<tr>
<td colspan="2" width="120" height="40" align="center"><input type="button" value=" C " name="btnCanc" onClick="buttonstore()"></td>
<td width="60" height="40" align="center"><input type="button" value=" / " name="btnDiv" onClick="buttonstore(/)"></td>
<td width="60" height="40" align="center"><input type="button" value=" x " name="btnMult" onClick="buttonstore(x)"></td>
</tr>
<tr>
<td width="60" height="40" align="center"><input type="button" value=" 7 " name="btn7" onClick="buttonstore(7)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 8 " name="btn8" onClick="buttonstore(8)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 9 " name="btn9" onClick="buttonstore(9)"></td>
<td width="60" height="40" align="center"><input type="button" value=" - " name="btnSub" onClick="buttonstore(-)"></td>
</tr>
<tr>
<td width="60" height="40" align="center"><input type="button" value=" 4 " name="btn4" onClick="buttonstore(4)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 5 " name="btn5" onClick="buttonstore(5)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 6 " name="btn6" onClick="buttonstore(6)"></td>
<td width="60" height="40" align="center"><input type="button" value=" + " name="btnAdd" onClick="buttonstore(+)"></td>
</tr>
<tr>
<td width="60" height="40" align="center"><input type="button" value=" 1 " name="btn2" onClick="buttonstore(1)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 2 " name="btn5" onClick="buttonstore(2)"></td>
<td width="60" height="40" align="center"><input type="button" value=" 3 " name="btn3" onClick="buttonstore(3)"></td>
<td rowspan="2" width="60" height="80" align="center"><input type="button" value=" = " name="btnEquals" onClick="buttonstore(=)"></td>
</tr>
<tr>
<td colspan="2" width="120" height="40" align="center"><input type="button" value=" 0 " name="btn0" onclick="buttonstore(0)"></td>
<td width="60" height="40" align="center"><input type="button" value=" . " name="btnDot"></td>
</tr>
</form>
</body>
</html>
Where to next? Any ideas??
Thanks