Write a javascript program to make a simple calculator
Answer Posted / raghav seth
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 ? | 63 Yes | 21 No |
Post New Answer View All Answers
How to convert javascript date to iso standard?
Is it possible to do 301 redirects in javascript ?
What does window.print() do in Javascript?
Program to return the address family of a socket
Does spread operator deep copy?
What is argument objects in javascript & how to get the type of arguments passed to a function?
How to create multiline strings in javascript?
How do I open javascript on my iphone?
Are javascript variables case sensitive?
How to find radio button selection when a form is submitted?
How do we get javascript onto a web page?
What are the pop-up boxes available in javascript?
How do you name a variable in javascript?
How to create the namespace in javascript?
Is javascript hard to learn?