checkbox - PHP Checkboxes won't undo disable attribute, but will uncheck -


i have few pages of long code, i'm having difficulty getting work. following script checks , and disables checkboxes id using onclick command on 1 main checkbox. when user unclicks box, checkmarks disappear, remain disabled. if hit reset button, disabled boxes stay.

javascript:

 <script>  function checkallbase(bx) {   var cbs = document.getelementsbytagname('input');   for(var i=0; < cbs.length; i++) {     if(cbs[i].id == '1') {       cbs[i].checked = bx.checked;       cbs[i].disabled=true;     }   } }  </script>  

give each checkbox input associated package similar name or class. without seeing actual html, supplying sample html below

html

<input type="checkbox" class="package1" name="package1[]" value="vacation"> <input type="checkbox" class="package1" name="package1[]" value="bonus"> <input type="checkbox" class="package1" name="package1[]" value="fries"> 

js

function togglepackage(ischecked,packagename) {   //choose 1 of 2 below use    //below selects inputs class name   var cbs = document.queryselectorall("input."+packagename);   //or below selects inputs input name   var cbs = document.queryselectorall("input[name^="+packagename+"]");    for(var i=0; i<cbs.length; i++) {         //since either checked , disabled (both true)         //or unchecked , enabled (both false) can use         //ischecked set both @ once.         cbs.checked = ischecked;         cbs.disabled = ischecked;   } }  //then somewhere call togglepackage function //bx here main checkbox want  //have toggling other boxes, , "package1" //the name or class gave checkboxes. togglepackage(bx.checked,"package1"); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -