Write a javascript program to make a simple calculator
Answer Posted / krishna
<html>
<form name="calculator">
<table border=4>
<tr>
<td>
<input type="text" name="text" size="18">
<br>
</td>
</tr>
<tr>
<td>
<input type="button" value="1" onclick="calculator.text.value += '1'">
<input type="button" value="2" onclick="calculator.text.value += '2'">
<input type="button" value="3" onclick="calculator.text.value += '3'">
<input type="button" value="+" onclick="calculator.text.value += ' + '">
<br>
<input type="button" value="4" onclick="calculator.text.value += '4'">
<input type="button" value="5" onclick="calculator.text.value += '5'">
<input type="button" value="6" onclick="calculator.text.value += '6'">
<input type="button" value="-" onclick="calculator.text.value += ' - '">
<br>
<input type="button" value="7" onclick="calculator.text.value += '7'">
<input type="button" value="8" onclick="calculator.text.value += '8'">
<input type="button" value="9" onclick="calculator.text.value += '9'">
<input type="button" value="*" onclick="calculator.text.value += ' * '">
<br>
<input type="button" value="c" onclick="calculator.text.value = ''">
<input type="button" value="0" onclick="calculator.text.value += '0'">
<input type="button" value="=" onclick="calculator.text.value = eval(calculator.text.value)">
<input type="button" value="/" onclick="calculator.text.value += ' / '">
<br>
</td>
</tr>
</table>
</form>
</html>
Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
What is the difference between textContent and innerText?
How do I use javascript to password-protect my web site?
What is variable typing in javascript?
Can you assign an anonymous function to a variable?
What does break and continue statements do in javascript?
What does the enableviewstatemac setting in an aspx page do?
What is difference between deep and shallow object coping in javascript?
What does javascript do?
What is javascript used for in web design?
What is use of JavaScript and jquery?
what is event bubbling and event capturing in javascript?
How to change video files randomly after completing its execution in Javascript?
What is node value?
What is shift() method in javascript?
What is the use of a weakset object in javascript?