Re: processing form checkboxes

From: Date: Thu, 24 Oct 2002 23:13:41 +0000
Subject: Re: processing form checkboxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-121365@lists.php.net to get a copy of this message
you need brackets, so when php initializes the variables, it knows to make the variable state an array. name=state[] -Matias "James Taylor" <jtx@hatesville.com> wrote in message news:DOEJIAGJHJHPBFMLOGOFKEJNCDAA.jtx@hatesville.com... > Heya folks, not sure if this is more of a php question or an html question, > though I'm right now leaning towards a 50% php, 50% html, so I think this is > on topic still. > > I have a form filled with checkboxes, each representing one of the 50 > states. A user can check as many states as they want, then post the data - > The checkbox form would look *something* like: > > <td><input type="checkbox" name="state" > value="1">&nbsp;&nbsp;Alabama</td> > <td><input type="checkbox" name="state" > value="2">&nbsp;&nbsp;Alaska</td> > <td><input type="checkbox" name="state" > value="3">&nbsp;&nbsp;Arizona</td> > > Instead of assigning a unique name to each checkbox, I know there's *some* > way to make it so the same name has multiple values, as I've seen it done > before (somehow). When posting the data though, the script is only > recognizing the box checked with the highest value > > foreach ($_POST as $value) { > echo "$value<br/>\n"; > } > > ^^^ Only shows the highest value > > Any ideas on how to do this without having to check for > isset($_POST['california']), isset($_POST['alabama']) etc. etc.? >

« previous php.general (#121365) next »