Abhay_R Posted June 13, 2019 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 Link to comment Share on other sites More sharing options...
HartleySan Posted June 13, 2019 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! Link to comment Share on other sites More sharing options...
Abhay_R Posted June 14, 2019 Author Share Posted June 14, 2019 Thanku HartleySan . Brother can you explain with example Link to comment Share on other sites More sharing options...
Abhay_R Posted June 14, 2019 Author 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 Link to comment Share on other sites More sharing options...
Larry Posted June 15, 2019 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. Link to comment Share on other sites More sharing options...
Recommended Posts