murfy Posted February 4, 2014 Share Posted February 4, 2014 (edited) 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 February 4, 2014 by murfy Quote Link to comment https://forums.phpfreaks.com/topic/285932-select-of-checkboxes/ Share on other sites More sharing options...
cyberRobot Posted February 4, 2014 Share Posted February 4, 2014 You have two forms named "form". Try changing the name of the table which doesn't have the checkboxes. Quote Link to comment https://forums.phpfreaks.com/topic/285932-select-of-checkboxes/#findComment-1467708 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.