Write a javascript program to make a simple calculator

Answer Posted / s.suresh

<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 ?    11 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is python better than javascript?

439


What is the ‘Strict’ mode in JavaScript and how can it be enabled?

554


What are the main features of javascript?

478


What is the difference between registerclientscriptblock and registerstartupscript?

493


What are the distinct types of error name values?

520






How generic objects can be created?

470


Explain prototypal/differential inheritance?

492


How can you get the total number of arguments passed to a function?

596


What is decodeuri() in javascript?

520


Why do we use javascript?

446


How do I open a website code?

506


What is difference between api and library?

476


Is javascript a security risk?

527


List out the different ways an HTML element can be accessed in a Javascript code?

721


Expand BOM and explain it?

500