Thanks for the reply!

Now Im getting 'document.form. calculations' is null or not an object.

Any ideas?

Here is the entire script:

<SCRIPT LANGUAGE="JavaS cript"><!--

// INVOICE CALCULATIONS

function calc(form) {

var sum = 0;

var rowsum;

var quantity = 1

// Add Lines (Line_Item_Subt otalx)

if ( parseFloat(form .Line_Qty1.valu e) &&

parseFloat(form .Line_Unit_Pric e1.value) ) {

quantity += parseInt(form.L ine_Qty1.value) ;

form.Line_Qty1. value = parseInt(form.L ine_Qty1.value) ;

form.Line_Unit_ Price1.value = parseFloat(form .Line_Unit_Pric e1.value);

rowsum = form.Line_Qty1. value * form.Line_Unit_ Price1.value;

sum += rowsum;

form.Line_Unit_ Price1.value = money(form.Line _Unit_Price1.va lue);

form.Line_Item_ Subtotal1.value = money(rowsum)

}

if ( parseFloat(form .Line_Qty2.valu e) &&

parseFloat(form .Line_Unit_Pric e2.value) ) {

quantity += parseInt(form.L ine_Qty2.value) ;

form.Line_Qty2. value = parseInt(form.L ine_Qty2.value) ;

form.Line_Unit_ Price2.value = parseFloat(form .Line_Unit_Pric e2.value);

rowsum = form.Line_Qty2. value * form.Line_Unit_ Price2.value;

sum += rowsum;

form.Line_Unit_ Price2.value = money(form.Line _Unit_Price2.va lue);

form.Line_Item_ Subtotal2.value = money(rowsum)

}

if ( parseFloat(form .Line_Qty3.valu e) &&

parseFloat(form .Line_Unit_Pric e3.value) ) {

quantity += parseInt(form.L ine_Qty3.value) ;

form.Line_Qty3. value = parseInt(form.L ine_Qty3.value) ;

form.Line_Unit_ Price3.value = parseFloat(form .Line_Unit_Pric e3.value);

rowsum = form.Line_Qty3. value * form.Line_Unit_ Price3.value;

sum += rowsum;

form.Line_Unit_ Price3.value = money(form.Line _Unit_Price3.va lue);

form.Line_Item_ Subtotal3.value = money(rowsum)

}

if ( parseFloat(form .Line_Qty4.valu e) &&

parseFloat(form .Line_Unit_Pric e4.value) ) {

quantity += parseInt(form.L ine_Qty4.value) ;

form.Line_Qty4. value = parseInt(form.L ine_Qty4.value) ;

form.Line_Unit_ Price4.value = parseFloat(form .Line_Unit_Pric e4.value);

rowsum = form.Line_Qty4. value * form.Line_Unit_ Price4.value;

sum += rowsum;

form.Line_Unit_ Price4.value = money(form.Line _Unit_Price4.va lue);

form.Line_Item_ Subtotal4.value = money(rowsum)

}

//GET SUBTOTAL

var total=0;

var theform = document.form["calculatio ns"];

for (var i=1; i<=n; i++) {

total += (theform["Line_Item_Subt otal"+i].value-0);

}

theform.subtota l.value = money(total);

}

function money(num) // converts from floating point to money format

{

var amount = Math.abs(num);

var pounds = Math.floor(amou nt);

var pence = Math.round( 100*(amount-pounds) );

if(pence>99) pence=0, pounds++;

pence += ""

while (pence.length < 2) pence = "0" + pence;

amount = pounds + "." + pence;

if (num < 0) return "[" + amount + "]";

return amount;

}

//-->

</SCRIPT>

"Matt Kruse" <ne********@mat tkruse.com> wrote in message

news:c9******** *@news1.newsguy .com...

Targa wrote: var sub1 = form.Line_Item_ Subtotal1.value

var sub21 = (sub1-0) + (sub2-0) + (sub3-0) + (sub4-0) .......>

form.subtotal.v alue = money(sub21)

How can this be written to work with any number of

Line_Item_Subto tal(n) fields?

something like:

var total=0;

var theform = document.form["formname"];

for (var i=1; i<=n; i++) {

total += (theform["Line_Item_Subt otal"+i].value-0);

}

theform.subtota l.value = money(total);

--

Matt Kruse

Javascript Toolbox: http://www.mattkruse.com/javascript/