Re: Unknown number of check boxes?
| From: | Jim Lucas | Date: | Tue, 29 May 2007 04:41:31 +0000 |
| Subject: | Re: Unknown number of check boxes? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255738@lists.php.net to get a copy of this message | ||
Søren Neigaard wrote:
Hi I would like to have a unknown number of generated check boxes like this: <input type="checkbox" name="chk01" /> <input type="checkbox" name="chk02" /> <input type="checkbox" name="chk0X" /><input type="checkbox" name="chk[]" value="Check box One" /> <input type="checkbox" name="chk[]" value="Check box Two" /> <input type="checkbox" name="chk[]" value="Check box Three" /> Then one the processor page, have it grab the "array" of indexed results being submitted.
if ( isset( $_REQUEST['chk']) &&is_array( $_REQUEST['chk']) &&
count( $_REQUEST['chk']) > 0 ) {
foreach ( $_REQUEST['chk'] AS $index => $value ) {
//Do something here with the checkboxes submitted
}
}
And the name will be generated "chk01 to chk99", but how do I make the receiving PHP script that "scans" for post variables that are sent, so that I can work on this information? Best regards Søren