NYCPHP Meetup

NYPHP.org

[nycphp-talk] Javascript and PHP arrays (Massive Redux)

Chris Bielanski Cbielanski at inta.org
Thu Jul 29 13:27:10 EDT 2004


Ah, yeah I put this one to bed with the help of some crazy Scandinavian...
;)

I was neglecting the trailing array subscript. The solution is now:

alert(document.form.elements["elemName[]"][N].value); 

displays the Nth value (zero-based) named "elemName[]" out of the form.

Thanks,
Chris Bielanski
Web Programmer, 
International Trademark Association,
1133 Avenue of the Americas, 33rd Floor
New York, NY 10036
+1 (212) 642-1745, f: +1 (212) 768-7796
mailto:cbielanski at inta.org, www.inta.org  
INTA -- 125 Years of Excellence



> -----Original Message-----
> From: Joshua Glenn [mailto:wheelie at acedsl.com]
> Sent: Thursday, July 29, 2004 1:19 PM
> To: NYPHP Talk
> Subject: RE: [nycphp-talk] Javascript and PHP arrays (Massive Redux)
> 
> 
> I just came across the same problem and solved it buy using
> getElementById().
> 
> ie:
> <name="array[]" id="array">
> 
> -josh
> 
> > Okay guys, I know we visit this every couple months. Please bear
> > with me :)
> >
> > Where is a good resource (php.net and google don't seem to 
> have answers I
> > can use) for validating the form with Javascript where the 
> form vars are
> > named with square-brackets so I can handle them as an array in PHP?
> >
> > Everything I've tried coughs up "undefined" for the value of the
> > form var in
> > question.
> 
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
> 



More information about the talk mailing list