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
How many types of variables are there in javascript?
What is the Infinity property used for in Javascript?
What is scope variable in javascript?
What does parse Query String return in javascript?
What output will this program produce System.out.println(x+"+"+y+"="+(x+));
What is array constructor in javascript?
What is unescape() function?
How to capture the Image width and height using QTP script ? Kindly answer plz.... Thanx in adavance...
What is primitive data type in javascript?
What is the difference between push() and concat() in javascript?
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.
Why is javascript hoisting?
How to encode and decode a url in javascript?
What is the data type of variables of in javascript?
What will happen if an infinite while loop is run in Javascript?