Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/273130-select-all-checkboxes-in-one-click/
Share on other sites

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?

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 by Dharmender

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 by requinix
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.