Not sure if this will accomplish what you want.
From a post earlier this month.
On this line, substitute the proper mathematical symbol for the plus
sign between the two "number value" fields to accomplish the function
you wish the script to perform:
Add = { result.value = +number1.value + +number2.value}
Mulitply = { result.value = +number1.value * +number2.value}
Subtract - { result.value = +number1.value - +number2.value}
Divide = { result.value = +number1.value / +number2.value}
------------------------>
in
message news
[email protected]...
I'm making a little page were I need the page to calculate. How can I do
that?
Try this
<html>
<head>
<script type="text/javascript">
function calcform()
{
with (document.form1)
{ result.value = +number1.value + +number2.value}
/*Note the extra + operator before each value. This is needed to
convert the
value from a string to a number.*/
}
</script>
</head>
<body>
Sum of Two Numbers
<form name="form1" action="">
Number 1:<br />
<input type="text" id="number1" value="" size="40" /><br/>
Number 2:<br />
<input type="text" id="number2" value="" size="40" /><br/>
Sum:<br />
<input type="text" id="result" value="" size="40" /><br/>
<input type="button" id="Calculate" value="Calculate"
onclick="calcform()" />
<input type="reset" id="reset" value=" Clear "/>
</form>
</body>
</html>