Thread: Calculator
View Single Post
Old Mar 7th, 2006, 4:32 AM   #1
Uday
Programmer
 
Join Date: Oct 2005
Location: India
Posts: 30
Rep Power: 0 Uday is on a distinguished road
Calculator

<html>
<head>
<title>
Calculator
</title>
<body bgcolor="pink">
<script language="javascript">
function add()
{
var i=0;
i=document.one.first.value + document.one.second.value;
document.write(i);
}

function sub()
{
var i=0;
i=document.one.first.value - document.one.second.value;
document.write(i);
}

function mul()
{
var i=0;
i=document.one.first.value * document.one.second.value;
document.write(i);
}

function div()
{
var i=0;
i=document.one.first.value/document.one.second.value;
document.write(i);
}

</script>
<form name="one">
Enter numbers
<input type="text" name="first" value="">
<input type="text" name="second" value="">
<p></p><input type="Submit" name="ADD" value="ADDITION" onClick="add()">
<input type="Submit" name="SUB" value="SUBSTRACT" onClick="sub()">
<input type="Submit" name="MUL" value="MULTIPLY" onClick="mul()">
<input type="Submit" name="DIV" value="DIVIDE" onClick="div()">
</form>
</body>
</html>

The code is working except the addition part. Any solution?

i.e
function add()
{
var i=0;
i=document.one.first.value + document.one.second.value;
document.write(i);
}
Uday is offline   Reply With Quote