Jump to content

select of checkboxes


murfy

Recommended Posts

I have a JS code to select elements in form (select all checkboxes of all messages), but it is not working and I cannot find why:

function sel() {
    with(document.form) {
        for(i=0;i<elements.length;i++) {
            thiselm = elements[i];
            if(thiselm.name.substring(0,3) == 'del')
                thiselm.checked = !thiselm.checked
        }
    }
}

Error message in Firebug:

elements is not defined:
for(i=0;i<elements.length;i++{

 

I found working code on different page, but this code does not work for this page with messages:

http://paste.ofcode.org/nN2ijGpxjjwd4ABRCsHmLj

 

So I have no idea how to fix that. Can you help? Or do you know Jquery and can you give me simple code in Jquery to do it with shorter code? I think that could be faster solution than to solve this complicated function

 

Example html with messages (utf8):

http://paste.ofcode.org/nKa2KUmpLrT2dNtRYayMV3

 

And demo with the problem:

http://jsfiddle.net/eD4VL/

Edited by murfy
Link to comment
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.