ILMV Posted April 14, 2009 Share Posted April 14, 2009 Hello All, I have a form with x amount of checkboxes on, I also have a button of which fires the following code to select / deselect all of the checkboxes: function checkAll() { // set the form to look at (your form is called form1) var frm = document.processPaymentsList // get the form elements var el = frm.elements // a variation to store whether any boxes are checked var testit = false; // loop through the elements... for(i=0;i<el.length;i++) { // check if the element is a checkbox and whether it is checked if (el[i].type == "checkbox" && el[i].checked == true) { // we have found a checked box so remember this! testit = true; } } // loop through the elements again... for(i=0;i<el.length;i++) { // and check if it is a checkbox if(el[i].type == "checkbox" ) { // if it is a checkbox and we have found a checked box if(testit == true) { // tick the box el[i].checked = false; } else { // otherwise untick the box el[i].checked = true; } } } } My problem is, whilst this code will happily select / deslect the check boxes, it will not fire each onChange individually, this is essential. Can anyone tell me how I can force an onChange in this script. Many Thanks, ILMV Link to comment https://forums.phpfreaks.com/topic/154026-problem-with-onchange/ Share on other sites More sharing options...
ILMV Posted April 14, 2009 Author Share Posted April 14, 2009 No worries! I used this code after each change: document.getElementById(el[i].id).onchange(); Thanks Me! Link to comment https://forums.phpfreaks.com/topic/154026-problem-with-onchange/#findComment-809657 Share on other sites More sharing options...
waynew Posted April 14, 2009 Share Posted April 14, 2009 You the man now dawg! Link to comment https://forums.phpfreaks.com/topic/154026-problem-with-onchange/#findComment-809959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.