calculator : For Addition(+), Subtraction(-), Multiplication(*), Division(/)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>calculator</title>
<script language="javascript">
function add()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1+value2
}
function sub()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1-value2
}
function multiply()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1*value2
}
function division()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1/value2
}
</script>
</head>
<body>
<center>
<h3> Calculator</h3>
<form name="calculate">
Enter the first value <input type="text" name="inputA" value="" size="8" />
Enter the second value <input type="text" name="inputB" value="" size="8" /><br />
<br /><br />
<input type="button" value="+" onclick="add()" />
<input type="button" value="-" onclick="sub()" />
<input type="button" value="*" onclick="multiply()" />
<input type="button" value="/" onclick="division()" />
<p> </p>
Result is <input type="text" name="output" size="8" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>calculator</title>
<script language="javascript">
function add()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1+value2
}
function sub()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1-value2
}
function multiply()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1*value2
}
function division()
{
var value1=document.calculate.inputA.value
var value2=document.calculate.inputB.value
document.calculate.output.value=value1/value2
}
</script>
</head>
<body>
<center>
<h3> Calculator</h3>
<form name="calculate">
Enter the first value <input type="text" name="inputA" value="" size="8" />
Enter the second value <input type="text" name="inputB" value="" size="8" /><br />
<br /><br />
<input type="button" value="+" onclick="add()" />
<input type="button" value="-" onclick="sub()" />
<input type="button" value="*" onclick="multiply()" />
<input type="button" value="/" onclick="division()" />
<p> </p>
Result is <input type="text" name="output" size="8" />
</form>
</body>
</html>
No comments:
Post a Comment