I’m trying to use the following javascript with multiple field names…
So where the name of the fields are firstBox,secondBox,thirdBox…
I need them to pass the field names like this:
firstBox1,secondBox1,thirdBox1
firstBox2,secondBox2,thirdBox2
and so on, to calculate correctly…
So I would have my input like this….
<input type=text name=”firstBox1″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> +
<input type=text name=”secondBox1″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> =
<input type=text name=”thirdBox1″>
<input type=text name=”firstBox2″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> +
<input type=text name=”secondBox2″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> =
<input type=text name=”thirdBox2″>
<!– Original Script BEGIN –>
<script type=”text/javascript”>
<!– This script and many more are available free online at –>
<!– The JavaScript Source!! [url]http://javascript.internet.com
<!– Created by: [url]www.jdstiles.com
<!– Begin
function startCalc(){
interval = setInterval(“calc()”,1);
}
function calc(){
one = document.autoSumForm.firstBox.value;
two = document.autoSumForm.secondBox.value;
document.autoSumForm.thirdBox.value = (one * 1) + (two
}
function stopCalc(){
clearInterval(interval);
}
// End –>
</script>
</HEAD>
<BODY>
<form name=”autoSumForm”>
<input type=text name=”firstBox” value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> +
<input type=text name=”secondBox” value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> =
<input type=text name=”thirdBox”>
</form>