Re: checkboxes and arrays
| From: | Steve Werby | Date: | Tue, 13 Feb 2001 03:29:43 +0000 |
| Subject: | Re: checkboxes and arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39320@lists.php.net to get a copy of this message | ||
"Christian Dechery" <lemming@vento.com.br> wrote:
> How can I associate a list of checkboxes to a list of texfields?
> but what if have:
> <input type=checkbox name=checklist[]>Cb1 <input type=text ...
> <input type=checkbox name=checklist[]>Cb2 <input type=text ...
>
> how would I associate each textfield to its checkbox? In the same array?
in
> a different one? How??
I would recommend generating these checkbox / text input field combos within
a loop and assign to separate arrays with the same key so you can match them
up when processing later. Like this:
$num_inputs = 5; // if you want 5 sets of checkboxes and text inputs.
for ( $i = 0; $i < $num_inputs; $i++ )
{
echo "<input type=checkbox name=checklist[$i]>Cb $i <input type=text
name=text[$i]>\n";
}
--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/