KittyKate Posted August 21, 2006 Share Posted August 21, 2006 I am feeling rather frustrated and braindead at this point... too many stupid HTML bugs in a day (if only I could at least say that they were because of me, but I'm suffering through another's code!).I've got the front end working at this point, but here is the setup and please tell me the name/value/id I need to set to get this thing to work.A pair of radio buttons trigger a javascript for one of two sets of checkboxes to be enabled. I can figure out which radio button was set, but I'm having issues parsing the checkboxes. The basic idea of the code I'm using is:[code]<?phpforeach($_POST['name'] as $value) { //add $value to database}?>[/code]Is this remotely correct? And will only the the ones that are checked show up, or do I need to test for that (and if so how)? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 21, 2006 Share Posted August 21, 2006 We need to see the source for your form.Ken Quote Link to comment Share on other sites More sharing options...
KittyKate Posted August 21, 2006 Author Share Posted August 21, 2006 Note: pseudo code!!!![code]<form name='name1'> <input type='radio' onclick='javascript(a)' name='type' value='a' id='a' />A <input type='radio' onclick='javascript(b)' name='type' value='b' id='b' />B <input type='checkbox' name='a' id='a#' value='#' />String <input type='checkbox' name='a' id='a#' value='#' />String ... <input type='checkbox' name='b' id='b#' value='#' />String <input type='checkbox' name='b' id='b#' value='#' />String ...</form>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted August 21, 2006 Share Posted August 21, 2006 But yes, only the checked checkbox info is postedCheck it out[code]<?phpif (isset($_POST['submit'])) { echo '<pre>', print_r($_POST, true), '</pre><hr>';} ?><FORM method='POST'><input type="checkbox" name="chkbox[1]" value="1"> 1 <BR/><input type="checkbox" name="chkbox[2]" value="2"> 2 <BR/><input type="checkbox" name="chkbox[3]" value="3"> 3 <BR/><input type="checkbox" name="chkbox[4]" value="4"> 4 <BR/><input type="checkbox" name="chkbox[5]" value="5"> 5 <BR/><input type="submit" name="submit" value="Submit"></FORM>[/code] Quote Link to comment Share on other sites More sharing options...
KittyKate Posted August 22, 2006 Author Share Posted August 22, 2006 Finally got it working. Thanks Barand! Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 22, 2006 Share Posted August 22, 2006 I never thought of using print_r with a true on it. I usually use if(isset($_POST['chkboz[]'])) because like Barand mentioned, they only get posted if they are checked.:) Quote Link to comment 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.