[Javascript] Form with array like structure
Peter Lauri
lists at dwsasia.com
Sun Jul 23 12:13:54 CDT 2006
Yes that helps, I can see that I have 14 elements and that is correct.
However, I have not been able to loop thru them? How do I do that? I tried
the following:
var inputelements = document.getElementsByTagName("input");
for(var i=0, len=inputelements.length; i<len; i++) {
document.write(inputelements[i].value+"<br>");
}
But that did not work :/
-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Steve Clason
Sent: Monday, July 24, 2006 4:27 AM
To: [JavaScript List]
Subject: Re: [Javascript] Form with array like structure
Peter Lauri wrote:
> I have a form that looks something like this:
>
> <form>
> <input type="text" name="thename[]"/>
> <input type="text" name="thename[]"/>
> <input type="text" name="thename[]"/>
> </form>
>
> In regular case, I can use document.getElementByName("thename").value to
> check the value of it, but how do I do now when one name has several. In
PHP
> it is treated as an array, but how can I look thru this with JavaScript?
document.getElementsByTagName("input") will get you an array of input
elements and you can loop through them looking for what you need.
I hope that helps some.
--
Steve Clason
Web Design & Development
Boulder, Colorado, USA
www.topdogstrategy.com
(303)818-8590
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list