newtomysql
Technical User
Dear All,
I have very simple javascript which I apply in my asp pages.
below is a snippet of my asp code first. here I am building dynamic name for each of record.
<input name="qty<%Response.Write Key%>" type="text" class="field-qty" onChange="orderTotal(this.form,'<%Response.Write Key%>')" value="<%=dictCart(Key)%>" size="5" maxlength="4" >
Here is my javascript code. I have purposely put alert(oform["qty1"]); which is suppose to take dynamic value. Even I have put a static value it give me undefined or sometimes it put [object]. I really cant see my problem here. Thanks.
function orderTotal(oform, prefix)
{
var qty = oform["qty1"];
alert(oform["qty1"]);
var price = oform["price"+prefix ];
var total = oform["total"+prefix ];
var subtotal = oform["subtotal"];
var temp = 0;
temp = subtotal.value - total.value;
temp2 = 0;
var hold;
// only bother if the field has contents
if (qty == "")return;
if(isNaN(qty.value) || (qty.value <= 0) || validate1(qty.value)==false)
{
qty.value = 1;
total.value = qty.value * price.value;
}
else
{
total.value = qty.value * price.value;
temp2 = Number(temp) + Number(total.value);
subtotal.value = temp2.toFixed(2);
document.forms.form1.submit();
}
}
I have very simple javascript which I apply in my asp pages.
below is a snippet of my asp code first. here I am building dynamic name for each of record.
<input name="qty<%Response.Write Key%>" type="text" class="field-qty" onChange="orderTotal(this.form,'<%Response.Write Key%>')" value="<%=dictCart(Key)%>" size="5" maxlength="4" >
Here is my javascript code. I have purposely put alert(oform["qty1"]); which is suppose to take dynamic value. Even I have put a static value it give me undefined or sometimes it put [object]. I really cant see my problem here. Thanks.
function orderTotal(oform, prefix)
{
var qty = oform["qty1"];
alert(oform["qty1"]);
var price = oform["price"+prefix ];
var total = oform["total"+prefix ];
var subtotal = oform["subtotal"];
var temp = 0;
temp = subtotal.value - total.value;
temp2 = 0;
var hold;
// only bother if the field has contents
if (qty == "")return;
if(isNaN(qty.value) || (qty.value <= 0) || validate1(qty.value)==false)
{
qty.value = 1;
total.value = qty.value * price.value;
}
else
{
total.value = qty.value * price.value;
temp2 = Number(temp) + Number(total.value);
subtotal.value = temp2.toFixed(2);
document.forms.form1.submit();
}
}