Jump to content

Problem with onChange


ILMV

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.