I have an order form with about 10 line items and am trying to write a reusable function for line price calculating. I pass in the price and fieldname prefix to my function, but it is not updating my 'total' field. It only updates the 'total' field when I hard code the left hand side of the assigment (see commented out line below).
I thought this had something to do with eval(), but have not been able to get that to fix it.
form fields:
<input type="text" name="chunkqty" size="10" onblur="calcsubtotal('3.25','chunk')"/>
<input type="text" name="chunktotal" size="7" />
function calcsubtotal(unitprice,productname) {
var myform = 'document.mglures.';
var subtotal;
var qtywidget = myform + [productname] + 'qty.value';
var totalwidget = myform + [productname] + 'total.value';
subtotal = [unitprice] * eval(qtywidget);
// update subtotal value
//document.mglures.chunktotal.value = subtotal;
totalwidget = subtotal;
}
Thanks,
Mickey
I thought this had something to do with eval(), but have not been able to get that to fix it.
form fields:
<input type="text" name="chunkqty" size="10" onblur="calcsubtotal('3.25','chunk')"/>
<input type="text" name="chunktotal" size="7" />
function calcsubtotal(unitprice,productname) {
var myform = 'document.mglures.';
var subtotal;
var qtywidget = myform + [productname] + 'qty.value';
var totalwidget = myform + [productname] + 'total.value';
subtotal = [unitprice] * eval(qtywidget);
// update subtotal value
//document.mglures.chunktotal.value = subtotal;
totalwidget = subtotal;
}
Thanks,
Mickey