Dharmender Posted January 14, 2013 Share Posted January 14, 2013 I have checkboxes with arrays like this foreach($result as $row) { <input type="checkbox" name="customers[]" value=$row['id'] />$row['name']<br>; } I want a CheckBox above all these on whose click all checkboxes of customer[] should be selected Quote Link to comment https://forums.phpfreaks.com/topic/273130-select-all-checkboxes-in-one-click/ Share on other sites More sharing options...
requinix Posted January 14, 2013 Share Posted January 14, 2013 Output the checkbox wherever you want it to be. Then attach some Javascript to its onclick so that all the name=customers[] checkboxes are checked. Are you using any Javascript framework, like jQuery or whatever else is still popular these days that isn't jQuery? Quote Link to comment https://forums.phpfreaks.com/topic/273130-select-all-checkboxes-in-one-click/#findComment-1405528 Share on other sites More sharing options...
Dharmender Posted January 14, 2013 Author Share Posted January 14, 2013 (edited) Output the checkbox wherever you want it to be. Then attach some Javascript to its onclick so that all the name=customers[] checkboxes are checked. Are you using any Javascript framework, like jQuery or whatever else is still popular these days that isn't jQuery? Using jquery. Can I select all checkboxes using single click in Jquery. How can I get the values of all checkboxes in jquery for single click action Edited January 14, 2013 by Dharmender Quote Link to comment https://forums.phpfreaks.com/topic/273130-select-all-checkboxes-in-one-click/#findComment-1405529 Share on other sites More sharing options...
requinix Posted January 14, 2013 Share Posted January 14, 2013 (edited) Can I select all checkboxes using single click in Jquery. Yes. How can I get the values of all checkboxes in jquery for single click action Do you actually want the values? They don't matter if all you want to do is select them. Give this a shot yourself and see how far you get and we can help you fix any problems you come across. An easy method would be to use a selector to find all checkboxes, .each() over them, and make each one checked if it's named "customers[]". Edited January 14, 2013 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/273130-select-all-checkboxes-in-one-click/#findComment-1405628 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.