Hi there,
I have a form with some arrayed text fields in it, a table with a fixed number of columns and a variable number of rows. All the fields in the first row have the same name as the fields in the second row and in the third row etc. Something like this:
Row 1: fieldA[1] fieldB[1] fieldC[1]
Row 2: fieldA[2] fieldB[2] fieldC[2]
.
.
Row n: fieldA[n] fieldB[n] fieldC[n]
(where [1], [2] and [n] are the array index numbers).
When data has been entered in fieldA and the field loses focus, the form is submitted (by an onfocusout-event) and refreshed, and fieldB is filled in automatically (the value is determined by a database-lookup).
My problem/question is this:
When the form is refreshed, I would like to put focus in the right row in my form table. I plan on using an onload-event for this, but I need to know which row had the focus before the refresh.
My onfocusout-event (on fieldA) looks like this:
onFocusout=customSubmit(this)
where customSubmit is defined like this:
function customSubmit(elem) {
document.getElementById(“currentField”).value = elem.name;
[form name].submit();
}
The idea is that the name of the “triggering” field is stored in the parameter currentField just before the form is submitted.
This ALMOST does what I want – except that the name stored in my currentField parameter is always “fieldA”, not “fieldA[1]” or “fieldA[2]” (i.e. the array index number is missing). Is there any way to include the index number in the name stored in the currentField parameter?