jaymc Posted December 28, 2006 Share Posted December 28, 2006 Really silly questionI have a dynamic PHP script on my page that generates checboxes for a formSo I may have 12 checkboxes..How can I call them up once submitted via php because if I set a name for them all as[code]<input type=checkbox name=list value=1><input type=checkbox name=list value=6><input type=checkbox name=list value=4><input type=checkbox name=list value=13><input type=checkbox name=list value=19>[/code]Obviously I cant do [b]echo $_POST['list'];[/b]Because thats only referring to one of those checkboxes. So how can I call them all up by name without naming them differently in the checkbox? The values will always be dynamic by the wayCheers Quote Link to comment https://forums.phpfreaks.com/topic/32016-checkbox/ Share on other sites More sharing options...
vbnullchar Posted December 28, 2006 Share Posted December 28, 2006 [code]<?if($_SERVER['REQUEST_METHOD']=='POST') {$a=$_POST['list'];print_r($a);}?><form method=POST><input type=checkbox name=list[] value=1><input type=checkbox name=list[] value=6><input type=checkbox name=list[] value=4><input type=checkbox name=list[] value=13><input type=checkbox name=list[] value=19><input type=submit></form>K[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32016-checkbox/#findComment-148610 Share on other sites More sharing options...
naeembhatti Posted December 28, 2006 Share Posted December 28, 2006 [code]<input type=checkbox name=list[] value=1><input type=checkbox name=list[] value=6><input type=checkbox name=list[] value=4><input type=checkbox name=list[] value=13><input type=checkbox name=list[] value=19>make it an array. <?just print the array.for($i=0; $i< count($_REQUEST['list']); $i++) { echo $_REQUEST['list'][$i]; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32016-checkbox/#findComment-148665 Share on other sites More sharing options...
pixeltrace Posted January 25, 2007 Share Posted January 25, 2007 hi,I am having this same kind of problem.what is will be the script on the second page?by the way my seconde page is a sendmail pageand i need to send the information from the checkboxwith <br>how do i do this?thanks! Quote Link to comment https://forums.phpfreaks.com/topic/32016-checkbox/#findComment-168636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.