<<Previous
<tr>
<td><input type="button" class="button black" value="0" onclick=
'onButtonPress("0")'></td>
<td><input type="button" class="button black" value="." onclick=
'onButtonPress(".")'></td>
<td><input type="button" class="button pink" value="/" onclick=
'onButtonPress("/")'></td>
<td><input type="button" class="button black" value="C" onclick=
'display("")'></td>
<td><input type="button" class="button orange" value="=" onclick=
'onEqual()'></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function display(val)
{
document.getElementById("display").value=val;
}
function onButtonPress(val)
{
document.getElementById("display").value+=val;
}
function onEqual()
{
try
{
display(eval(document.getElementById("display").value))
}
catch(onEqual)
{
display('Error')
}
}
</script>
</body>
</html>
<tr>
<td><input type="button" class="button black" value="0" onclick=
'onButtonPress("0")'></td>
<td><input type="button" class="button black" value="." onclick=
'onButtonPress(".")'></td>
<td><input type="button" class="button pink" value="/" onclick=
'onButtonPress("/")'></td>
<td><input type="button" class="button black" value="C" onclick=
'display("")'></td>
<td><input type="button" class="button orange" value="=" onclick=
'onEqual()'></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function display(val)
{
document.getElementById("display").value=val;
}
function onButtonPress(val)
{
document.getElementById("display").value+=val;
}
function onEqual()
{
try
{
display(eval(document.getElementById("display").value))
}
catch(onEqual)
{
display('Error')
}
}
</script>
</body>
</html>
Output:
<<Previous
No comments:
Post a Comment