Jim-
The lines var price = "" + parseFloat(Base_price); AND price = "" + parseFloat(Option_price);
look suspect to me; adding a string to a floating point number may create a NaN situation.
Dave
<SCRIPT Language="JavaScript"> calculateSubtotal();
function calculateSubtotal() { var Base_price = document.frmBTO.baseprice.value; var price = "" + parseFloat(Base_price); var subtotal = 1 * price;
for (i = 0 ; i < document.frmBTO.elements.length ; i++) { if (document.frmBTO.elements[i].name.substring(0,8) == "ctrlBTO_") { Option_index = document.frmBTO.elements[i].selectedIndex; Option_price = document.frmBTO.elements[i].options[Option_index].price; price = "" + parseFloat(Option_price); subtotal += 1 * price; // subtotal += quantity * price; } } // convert subtotal to a string var subtotaltext = subtotal + ""; var decimalstart = subtotaltext.indexOf("."); if (decimalstart > 0) { subtotaltext = subtotaltext.substring(0,decimalstart+3); } if (decimalstart < 1) { subtotaltext = subtotaltext + ".00"; } if (subtotaltext.substring(decimalstart+1).length < 2) { subtotaltext = subtotaltext + "0"; } document.frmBTO.subtotal.value = subtotaltext; //document.getElementById("lblPrice").innerText = subtotaltext; //alert(document.getElementById("lblPrice").innerText); } </SCRIPT>
©2006 Dave Bernard |