kennywhite

Oct 15th, 2010, 07:13 PM

Hello.

I have been struggling with figuring this out on my own for over a week and have had no luck, so it is time to ask for some guidance. The idea of this seemed very simple, but I may just be too much of a Javascript noob to figure it out.

I have a form where users will enter in orders that have been returned to us. They will enter in the part numbers returned, the quantity of each part number, and the quantity of the part that was returned damaged.

I need to be able to add up the total quantity in one input box and the total damaged quantity in another input box.

The input boxes are named Quantity1, Quantity2, DamagedQTY1, DamagedQTY2, and so on.

There could be up to 100 different part numbers on each order, so I would need to loop through 100 input boxes.

Here is the sample code that I found and started trying to customize. I was unable to figure out how to get the loop or the second set of numbers to be added to work.

<script type="text/javascript">

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 * 1);

}

function stopCalc(){

clearInterval(interval);

}

</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>

Thank you in advance for any help!

I have been struggling with figuring this out on my own for over a week and have had no luck, so it is time to ask for some guidance. The idea of this seemed very simple, but I may just be too much of a Javascript noob to figure it out.

I have a form where users will enter in orders that have been returned to us. They will enter in the part numbers returned, the quantity of each part number, and the quantity of the part that was returned damaged.

I need to be able to add up the total quantity in one input box and the total damaged quantity in another input box.

The input boxes are named Quantity1, Quantity2, DamagedQTY1, DamagedQTY2, and so on.

There could be up to 100 different part numbers on each order, so I would need to loop through 100 input boxes.

Here is the sample code that I found and started trying to customize. I was unable to figure out how to get the loop or the second set of numbers to be added to work.

<script type="text/javascript">

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 * 1);

}

function stopCalc(){

clearInterval(interval);

}

</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>

Thank you in advance for any help!