I have a form that dynamically creates checkboxes. I want to put a checkbox above those so that the user can click on it to check/uncheck all of them at once. But I can't figure out how to find the checkboxes. Here's what I am trying to do:
This creates the single checkbox that I want to click to toggle all the others.
I know I will need to do a loop to see them all but I used the following just to see if the basic code is working. But when I click on the main checkbox, nothing is displayed. If I change the alert to alert(elm.length);, it displays the total number of input form elements, as expected. Would someone please point out my mistake or let me know if there is a better way to do this?
var elm = document.getElementsByTagName("input");
Thanks a lot It's certainly very useful to implement this on any site that has many checkboxes. Also, I like Gmail's approach of holding down shift and clicking the first and last checkbox, and it fills in all the rest between. That's very useful.
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.