RE: [PHP] Multiple checkboxes and multiple textboxes
| From: | Vail, Warren | Date: | Fri, 05 Nov 2004 19:54:27 +0000 |
| Subject: | RE: [PHP] Multiple checkboxes and multiple textboxes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201312@lists.php.net to get a copy of this message | ||
Hard code the array occurrence number in the checkbox and textbox names;
<input type=checkbox name=url[1] value='http://somesite'
checked> <a href='http://somesite'
checked> target=a>somesite</a>
<br><input type=text name=txt[1] size=75 value='some desc'>
The form will only return the checkboxes that are checked and the textboxes
will return all textboxes (that is the nature of these input controls with
most browsers);
$urls = $_POST["url"];
$temptexts = $_POST["txt"];
Foreach($urls as $no => $val) {
$txt[$no] = $temptxts[$no];
}
Now $txt contains only matching text fields.
Hope this helps,
Warren Vail
> -----Original Message-----
> From: Ryan A [mailto:ryan@coinpass.com]
> Sent: Friday, November 05, 2004 11:28 AM
> To: php-general@lists.php.net
> Subject: [PHP] Multiple checkboxes and multiple textboxes
>
>
> Hi,
> I have a form that has something like this:
>
> <input type=checkbox name=url[]
> value='http://somesite'
> checked> <a href='http://somesite'
> checked> target=a>somesite</a>
> <br><input type=text name=txt[] size=75 value='some desc'>
>
> <input type=checkbox name=url[]
> value='http://somesite1'
> checked> <a href='http://somesite1'
> checked> target=a>somesite1</a>
> <br><input type=text name=txt[] size=75 value='some desc1'>
>
> <input type=checkbox name=url[]
> value='http://somesite2'
> checked> <a href='http://somesite2'
> checked> target=a>somesite2</a>
> <br><input type=text name=txt[] size=75 value='some desc2'>
>
> As you can see from the above, theses a checkbox (url[])
> which holds the value of the URL and a textbox (txt[]) which
> holds some description text, in the above there are only 3
> rows but actually there are 200 per page. When the form is
> submitted how do I make sure that if url[] is unchecked even
> txt[] should not be taken?
>
> These values will be entered into the database so I need
> proper "matching pairs" of URL and TXT
>
> Thanks,
> Ryan
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>