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


Please Help Members By Posting Answers For Below Questions

What is the difference between typeof and instanceof operators in Javascript?

574


What is the use of a weakset object in javascript?

541


What is a module code?

530


How can we detect os of the client machine using javascript?

532


What javascript means?

489






How to delete a cookie using javascript?

531


Which software is used for javascript?

472


How javascript variables work?

464


How to toggle display an html element?

555


What is the javascript function?

531


What would be the result of 2+5+”3″?

534


What is a named function in JavaScript? How to define a named function?

533


What is NaN?

567


Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

568


How do you organize your JavaScript code?

599