ocularis
11-25-2002, 10:33 PM
Hi,
I have a dynamically created array of form elements (text boxes). I set an onblur event for each one. Since the elements all have the same name, how do I determine the subscript of the element which triggered the onblur event? I need to obtain the subscript itself to be able to synchronize this change with an adjacent array of text boxes. I am only vaguely familiar with the use of the "this" statement.
example:
(double quotes are there because I create the page as an ASP)
<input type=""text"" size=""5"" name=""Qty"" onBlur=""calcPrice();""/>
function calcPrice(){
var theIndex;
theIndex= document.orderfrm.Qty.Index;
window.alert('the index is' + theIndex);
document.orderfrm.Extprice[theIndex].value= document.orderfrm.Qty[theIndex].value *
jsarray[theIndex][4];
}
jsarray is an array I have populated from a database. The 4th column contains a price field. I guess there is no property called "Index" for form elements because I get a syntax error. Also the alert window says the value is null. How do I obtain the index/subscript for this element?
Thanks in advance for any help!
I have a dynamically created array of form elements (text boxes). I set an onblur event for each one. Since the elements all have the same name, how do I determine the subscript of the element which triggered the onblur event? I need to obtain the subscript itself to be able to synchronize this change with an adjacent array of text boxes. I am only vaguely familiar with the use of the "this" statement.
example:
(double quotes are there because I create the page as an ASP)
<input type=""text"" size=""5"" name=""Qty"" onBlur=""calcPrice();""/>
function calcPrice(){
var theIndex;
theIndex= document.orderfrm.Qty.Index;
window.alert('the index is' + theIndex);
document.orderfrm.Extprice[theIndex].value= document.orderfrm.Qty[theIndex].value *
jsarray[theIndex][4];
}
jsarray is an array I have populated from a database. The 4th column contains a price field. I guess there is no property called "Index" for form elements because I get a syntax error. Also the alert window says the value is null. How do I obtain the index/subscript for this element?
Thanks in advance for any help!