Re: checkbox => POST => array??
| From: | Brent Baisley | Date: | Mon, 12 Aug 2002 14:56:41 +0000 |
| Subject: | Re: checkbox => POST => array?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112144@lists.php.net to get a copy of this message | ||
I'm doing something very similar on a project I'm working on, except I'm using radio buttons. I'm not quite sure what are using the ID for (for style sheets or a data ID). If you are using it as a data ID, then you can make it part of the topic[] array. So it would look like this:
<input type='checkbox' name="topic['45']" value='a value'>
Then to process the array, you would do something like this:
while (list($checkboxID,$checkboxValue) = each $topic) {
// Your process code
}
Each check box is then referenced by the two variables $checkboxID and $checkboxValue. There are a number of ways ou can do this, really any way you would process and array (i.e. foreach). I prefer this way because I can give logical names to the array elements I am using.
On Saturday, August 10, 2002, at 02:56 PM, PeterV wrote:
I, I don't have my books here and it's been a while since I did PHP, and google isn't helping: How do I code a bunch of checkboxes with id's, and then loop trough the result as an array after POSTing it? What I have now: <input type='checkbox' id='45' name='topic[]' value='45'> doesn't return an array $topic?? Thanks, Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577