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


Please Help Members By Posting Answers For Below Questions

How to convert javascript date to iso standard?

511


Is it possible to do 301 redirects in javascript ?

474


What does window.print() do in Javascript?

587


Program to return the address family of a socket

824


Does spread operator deep copy?

534






What is argument objects in javascript & how to get the type of arguments passed to a function?

471


How to create multiline strings in javascript?

486


How do I open javascript on my iphone?

482


Are javascript variables case sensitive?

480


How to find radio button selection when a form is submitted?

440


How do we get javascript onto a web page?

473


What are the pop-up boxes available in javascript?

486


How do you name a variable in javascript?

461


How to create the namespace in javascript?

551


Is javascript hard to learn?

487