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
How use javascript html?
Explain the unshift() method ?
Which built-in method returns the index within the calling string object of the first occurrence of the specified value?
How do I run code in browser console?
What is a frontend framework?
Where can I learn javascript for beginners?
What is viewstate in javascript?
What is the === in javascript?
What is question mark in javascript?
what is the difference between window & document in javascript?
Why would you use a sticky session?
Write a program to exaplain the deferred scripts using event handlers in javascript.
How many types of variables are there in javascript?
Can an anonymous function be assigned to a variable?
How Can I get facebook fans/likes?