[TriLUG] Stuck in a rut

Brian McCullough bdmc at bdmcc-us.com
Tue Sep 15 16:08:18 EDT 2009


Folks,

I know that I can't see the forest because I have my head stuck in a tree, so I hope somebody can gently put me back on the path.

( This is a Javascript question. )


I have a form, something like:


<form name='example' >
<p >some text</p >
<input type='text' name='ex-1' >
<input type='text' name='ex-1' >
<p >some text</p >
<input type='text' name='ex-2' >
<input type='text' name='ex-2' >
<input type='text' name='ex-2' >
<p >some text</p >
<input type='text' name='ex-3' >
</form >


As you can see, I have some arrays of text strings being collected.  While I know the number of groups to expect, the number of elements in each group is variable.

Not necessarily describing the problem well, but I would like to be able to address each element through JS and manipulate them.

I have tried:

var name = 'ex-' + counter;
var len  = document.example.name.length;

and get variations on "undefined".

I have tried:

var name = 'document.example.ex-' + counter;
var len  = name.length;

and I get the length of "name," not the number of elements in the array.

I tried a while loop, using "name" as defined above, and checking for "name[i]" to be undefined, but it seems to be always defined, no matter what input I give it.


Any bright ideas?


Thank you,
Brian




More information about the TriLUG mailing list