jerald717 Posted February 9, 2011 Share Posted February 9, 2011 Hi, so i have a problem. I'm using a script to enable and disable checkboxes, and i'm id-ing them fetching values from a database: while($data = mysqli_fetch_array($sql)) { if ($count % 5 == 0) { echo '</tr><tr>'; $count = 0; } echo '<td><input name="subject_level[]" class="subject_a" disabled="disabled" type="checkbox" id="subject_level_'.$data['subject_level_id'].'" value="'.$data['subject_level_id'].'"/>'; echo '<label for="subject_level_'.$data['subject_level_id'].'" class="subject_1">'.$data['subject_name'].'</label></td>'; $count++; //Increment the count } The names of the checkboxes come out fine, just that, is there any way to retrieve the values of the checkboxes into an array of some sort so that i could build a search query later? if($_POST(subject_level)) or if($_POST(subject_level[])) doesn't return true. does it make sense? im new to php so please forgive my ignorance. Help appreciated. Thanks! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2011 Share Posted February 9, 2011 $_POST['subject_level'], not $_POST(subject_level) Quote Link to comment Share on other sites More sharing options...
jerald717 Posted February 9, 2011 Author Share Posted February 9, 2011 I actually meant $_POST['subject_level'] , apologies. That isn't working either. is there an issue accessing the checkbox values because of the echo? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2011 Share Posted February 9, 2011 Just noticed the disabled="disabled" attribute in there. With that attribute set, the value isn't sent in the $_POST array at all. Quote Link to comment Share on other sites More sharing options...
jerald717 Posted February 9, 2011 Author Share Posted February 9, 2011 I see. Yea I'm using a javascript to enable or disable the checkbox. Won't the value be changed through js? The reason I'm using javascript to do that is because I want to enable/disable a group of checkboxes using one checkbox. I'll see if I can post that script up after lunch. It could help if anyone could refer me to a thread or tutorial that does this? Will need to use the Id values of the checkbox to build search queries. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted February 9, 2011 Share Posted February 9, 2011 When it comes to js, I'm pretty much useless. Sorry. Quote Link to comment Share on other sites More sharing options...
jerald717 Posted February 9, 2011 Author Share Posted February 9, 2011 Alright, thanks man. for anyone else who could help, the js script i'm using to enable/disable my checkboxes is put below. I have set the default for the checkboxes as disabled, but somehow the js doesnt seem to be enabling them. Alternatively, if anyone could refer me to a tutorial/thread which has got to do with a similar problem, let me know thanks! <script type="text/javascript"> $(document).ready(function() { //Level_1 and subject_a $('label.subject_1').toggleClass('inactive'); $('#level_1').click(function() { $('label.subject_1').toggleClass('active'); $('.subject_a').each(function() { $(this).attr('disabled', !$(this).attr('disabled')); $(this).attr('checked', false); }) });// end click() </script> 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.