Forum Moderators: open

Message Too Old, No Replies

php array as form value

         

Vladd44

12:37 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



<form name="myform" action="preview.php" method="post">

<input type="text" name="pagename['.$i.']" value="'.$defpn.'" '.$dis.'>

which of course outputs as a form with input boxed named pagename[1] followed by a pagename[2] etc.

I have tried to use various javascript options to require the field not being empty, but none seem to work.

Testing it out without the [] in the name resolves the issue, but rewriting to accomodate this is something I would really rather avoid due to the fact that more than a few pages rely on them being the way they are and would all require considerable time to even find them all.

Any ideas on how to get this working? Or should I just start rewriting them all?

music_man

4:08 am on Apr 8, 2007 (gmt 0)

10+ Year Member



Hi there,

Are you wanting all the form fields to be validated? And, are you set on having javascript validate it, or would you consider php?

coopster

8:56 pm on Apr 9, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have found it easiest to add an "id" attribute to the input elements. You can always access them through "elements" array too though. The PHP and HTML [php.net] FAQ shows the latter example.