Abhay_R 0 Posted June 13, 2019 Report Share Posted June 13, 2019 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 Quote Link to post Share on other sites
HartleySan 826 Posted June 13, 2019 Report Share Posted June 13, 2019 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! Quote Link to post Share on other sites
Abhay_R 0 Posted June 14, 2019 Author Report Share Posted June 14, 2019 Thanku HartleySan . Brother can you explain with example Quote Link to post Share on other sites
Abhay_R 0 Posted June 14, 2019 Author Report Share Posted June 14, 2019 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 Quote Link to post Share on other sites
Larry 428 Posted June 15, 2019 Report Share Posted June 15, 2019 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. Quote Link to post Share on other sites
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.
Note: Your post will require moderator approval before it will be visible.