PDA

View Full Version : HTML Form input to be used for math calculations


KyleS
01-07-2010, 04:24 PM
I've simplified what my actual code for posting purposes (i'm actually capturing about 20 values, but i figure if I can get one to work, I can get 20). I've been having problems getting Javascript to capture input from the user in an HTML input and doing some math on the captured values, then returning the newly calculated values into a new box.

<html><head>
<script type="text/javascript">
function calculate()
{
var chartPull = calc.chartPull.value;
var total = chartPull * 10;
calc.total.value = total;
return false;
}
</script></head>

<body>
<form name="calc" action="" method="post">
<input type="text" name="chartPull" size="10" value="0">
<input type="button" value="Calculate" onclick="calculate()" />
<input type="text" name="total" readonly="readonly" />
</form></body></html>


thanks for thelp!

abduraooft
01-07-2010, 04:34 PM
var chartPull = document.calc.chartPull.value;
var total = chartPull * 10;
document.calc.total.value = total;