tampa03
10-13-2003, 06:31 AM
I am trying (without success) to insert an array into... formObj.elements[ARRAY GOES HERE].value
- I have a form with multiple arrays that are passed to functions
- Function description
function calculate_row_total(formObj,x)
{
parseFloat(formObj.elements['q_index'][x].value);
etc...
}
- the variable 'q_index' is an array used to name multiple form fields.
Any ideas? Thanks in advance.
beetle
10-13-2003, 07:37 AM
And what does x represent? The index of the array to use?
function calculate_row_total(formObj,x)
{
parseFloat(formObj.elements[q_index[x]].value);
}
tampa03
10-13-2003, 02:00 PM
Thanks for your reply.
Yes. The variable x represents the index of the array, defined in the form.
I received the following error when removing the single quotes from the 'parseFloat(formObj.elements[q_index][x].value);'
ERROR : q_index is undefined.
Here is my function:
----------------------------------------
function calculate_row_total(formObj,x)
{
var quantity = parseFloat(formObj.elements[q_item_row[x]].value);
var price = parseFloat(formObj.elements[unit_price_row[x]].value);
var total = quantity * price;
formObj.elements[total_row[x]].value = total;
}
-----------------------------------------------
tampa03
10-13-2003, 02:00 PM
I've used similar notation with succes. The following line works without problems:
formObj.elements['total_all'].value = rows_total;
The errors appear when I attempt to insert an array inside elements[ARRAY HERE].
Perhaps the problem is related to concatenation? Any suggestions?
Thanks.