C
chumley
I have a simple orderform, whereas when I enter the quantity in the
first box, it calcuates the subtotal fine, but when i go down to the
second item and enter a quantity , the subtotal doesnt calculate, but
enters a "NaN" not a number indicator and not the calculated subtotal,
even tho i have the first product coded exactly like the second one:
function orderTotal(oform, prefix)
{
// set references to fields
var qty = oform[prefix + "_qty"];
var stHold = oform[prefix + "_stHold"];
var price = oform[prefix + "_price"];
var stVis = oform[prefix + "_stVis"];
// only bother if the field has contents
if (qty == "")return;
// if the with is not a number (NaN)
// or is zero or less
// everything goes blank
if(isNaN(qty.value) || (qty.value <= 0))
{
qty.value = "";
stHold.value = "";
}
// else the field is a valid number, so calculate the
// total order cost and put that value in the
// hidden subtotal field
else
{
stHold.value = (Math.round(qty.value * price.value * 100))/100;
}
// call the routine which checks if the
// visible subtotal is correct
visTotal(oform, prefix);
}
// checks if the visible subtotal is correct
// ie, if it equals the hidden subtotal field
function visTotal(oform, prefix)
{
var stHold = oform[prefix + "_stHold"];
var stVis = oform[prefix + "_stVis"];
if (stVis.value != stHold.value)
stVis.value = stHold.value;
}
/////////html
<form>
<INPUT
TYPE=TEXT
NAME="vn_qty"
SIZE=3
onChange="orderTotal(this.form, 'vn')"<INPUT TYPE=HIDDEN NAME="vn_price" VALUE="270.00">$270.00
<INPUT TYPE=HIDDEN NAME="vn_stHold">
<INPUT
TYPE=TEXT
NAME="vn_stVis"
SIZE=10
onChange="visTotal(this.form, 'vn')"<!--second input box, this one is the one not working -->
<INPUT
TYPE=TEXT
NAME="ja_qty"
SIZE=3
onChange="orderTotal(this.form, 'ja')"<INPUT TYPE=HIDDEN NAME="ja_price" VALUE="195.00">$195.00
<INPUT TYPE=HIDDEN NAME="ja_stHold">
<INPUT
TYPE=TEXT
NAME="ja_stVis"
SIZE=10
onChange="visTotal(this.form, 'ja')"
???
chumley
first box, it calcuates the subtotal fine, but when i go down to the
second item and enter a quantity , the subtotal doesnt calculate, but
enters a "NaN" not a number indicator and not the calculated subtotal,
even tho i have the first product coded exactly like the second one:
function orderTotal(oform, prefix)
{
// set references to fields
var qty = oform[prefix + "_qty"];
var stHold = oform[prefix + "_stHold"];
var price = oform[prefix + "_price"];
var stVis = oform[prefix + "_stVis"];
// only bother if the field has contents
if (qty == "")return;
// if the with is not a number (NaN)
// or is zero or less
// everything goes blank
if(isNaN(qty.value) || (qty.value <= 0))
{
qty.value = "";
stHold.value = "";
}
// else the field is a valid number, so calculate the
// total order cost and put that value in the
// hidden subtotal field
else
{
stHold.value = (Math.round(qty.value * price.value * 100))/100;
}
// call the routine which checks if the
// visible subtotal is correct
visTotal(oform, prefix);
}
// checks if the visible subtotal is correct
// ie, if it equals the hidden subtotal field
function visTotal(oform, prefix)
{
var stHold = oform[prefix + "_stHold"];
var stVis = oform[prefix + "_stVis"];
if (stVis.value != stHold.value)
stVis.value = stHold.value;
}
/////////html
<form>
<INPUT
TYPE=TEXT
NAME="vn_qty"
SIZE=3
onChange="orderTotal(this.form, 'vn')"<INPUT TYPE=HIDDEN NAME="vn_price" VALUE="270.00">$270.00
<INPUT TYPE=HIDDEN NAME="vn_stHold">
<INPUT
TYPE=TEXT
NAME="vn_stVis"
SIZE=10
onChange="visTotal(this.form, 'vn')"<!--second input box, this one is the one not working -->
<INPUT
TYPE=TEXT
NAME="ja_qty"
SIZE=3
onChange="orderTotal(this.form, 'ja')"<INPUT TYPE=HIDDEN NAME="ja_price" VALUE="195.00">$195.00
<INPUT TYPE=HIDDEN NAME="ja_stHold">
<INPUT
TYPE=TEXT
NAME="ja_stVis"
SIZE=10
onChange="visTotal(this.form, 'ja')"
???
chumley