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/

Link to comment
https://forums.phpfreaks.com/topic/285932-select-of-checkboxes/
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.