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

How many types of variables are there in javascript?

423


What is the Infinity property used for in Javascript?

560


What is scope variable in javascript?

508


What does parse Query String return in javascript?

526


What output will this program produce System.out.println(x+"+"+y+"="+(x+));

1561






What is array constructor in javascript?

507


What is unescape() function?

622


How to capture the Image width and height using QTP script ? Kindly answer plz.... Thanx in adavance...

3614


What is primitive data type in javascript?

477


What is the difference between push() and concat() in javascript?

526


A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.38, and the profit of each carton of milk is $0.27. Write a java program that prompts the user to enter the total amount of milk produced in the morning. Then display the number of milk cartons needed to hold milk, the cost of producing milk, and the profit for producing milk.

1609


Why is javascript hoisting?

456


How to encode and decode a url in javascript?

536


What is the data type of variables of in javascript?

491


What will happen if an infinite while loop is run in Javascript?

507