Re: checkbox question

From: Date: Tue, 10 Sep 2002 14:12:26 +0000
Subject: Re: checkbox question
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-115850@lists.php.net to get a copy of this message
This will work: http://www.php.net/array_merge Call your checkboxes like so: a.php ========================================== <form action="b.php" method="post"> <input type="checkbox" name="a1" value="A"><br> <input type="checkbox" name="a2" value="B"><br> <input type="checkbox" name="a3" value="C"><br> <input type="checkbox" name="a4" value="D"><br> <input type="checkbox" name="a5" value="E"><br> <input type="checkbox" name="a6" value="F"><br> <input type="submit" name="submit" value="SUBMIT"> </form> ========================================== then post it to the desired page and do something like this: b.php ========================================== <?php $foo = array_merge($_POST['a1'],$_POST['a2'],$_POST['a3'],$_POST['a4'],$_POST['a5'] ,$_POST['a6']); echo $foo; // Returns an array echo "<pre>"; print_r($foo); // Look whats in the array echo "</pre>"; ?> ========================================== Best of luck, Craig "B.C. Lance" <lornie@magix.com.sg> wrote in message news:3D7DEA9E.4030706@magix.com.sg... > if you can't use [] for the checkbox, the only way out is to have unique > name for each checkbox. > > otherwise, php will always be returning the value of the last checked > checkbox if all checkboxes share the same name without the []. > > --lance > > Alex Shi wrote: > > How to ontain data from a group of checkbox using same name? > > For example, in a form there're 6 checkboxes and all named as > > "Interesting_Area". I know if put a pairs of square brackets at the > > end of the name then in php all the values of them can be ontained. > > However, for some reason I cannot use square brackets. Please > > help me out if anyone know how to do the trick. THanks! > > > > Alex > > > > >

« previous php.general (#115850) next »