Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.