Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Abhay_R

When checkbox is checked, disable other checkboxes

Recommended Posts

When checkbox is checked, disable other checkboxes 

Question : 1.When one particular value checkbox is checked out of many checkbox in 1st div then disable same value checkbox in 2nd and 3rd div  

                   2.When one particular value checkbox is checked out of many checkbox in 2nd div then disable same value checkbox in 1st and 3rd div  

                   3.When one particular value checkbox is checked out of many checkbox in 3rd div then disable same value checkbox in 1st and 3rd div  

How can we do this with javascript or J query

Share this post


Link to post
Share on other sites

Disabling a checkbox in JS is actually really easy. You simply do the following:

checkboxDomElem.disabled = true;

And you can toggle the checkbox back on by setting disabled to false.

The trick is writing the correct logic in your JS (or PHP, and then pass it over to your JS) that knows that when you click a particular checkbox in the first row to disable three particular checkboxes in the second row, etc., etc.

For that, there are any number of things you can do, but I personally prefer Vue.js these days. It's an extremely powerful JS framework that makes this stuff easy. With it, you essentially just have to pass it a dependency tree, so that it knows which checkboxes are conditionally dependent on which others and you're done.

Good luck!

Share this post


Link to post
Share on other sites

Hi HartleySan,

Actually in three separate  div common 1 to 20 data retrieve from database so all three div have same 1 to 20 data . my moto in all three div same data so all row also same in three div . So if first row select in first div then same first row hidden of other two div . So user if select one data then user can't select same data in other two box . its help to restriction  to select same data in different different div

Share this post


Link to post
Share on other sites

The key to figuring this out is remember that if multiple radio buttons have the same name, only one can be checked. So just write your code to create the proper names based upon the restriction you want to put in place.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...