function checkall() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=1)
}
Perhaps someone with javascript knowledge can tell me how to best expand this to do what I want?
function checkall() {
void(d=document);
void(el=d.getElementsByTagName('INPUT'));
for(i=0;i<el.length;i++)
void(el[i].checked=1)
}
function myFinder(el) {
return findParentNode(el, "FORM", "", "myformid");
}
Now, if you have an array of elements and say
filtered = filterByParent(myCollection, myFinder);
what will happen is that the filtered array will contain only those elements who happen to be descendants of a FORM tag with id="myformid".
You can also get fancy and write myFinder inline:
filtered = filterByParent(
myCollection,
function(el) {return findParentNode (el, "FORM", "", "myformid");}
);
This will do the exact same thing.
As a last, practical example, here is a function that when executed will check all the "attempt" checkboxes in the quiz overview page based on the principle that they are in a FORM. If you try to add some checkboxes outside a FORM in the same page (this is useless practically, but enough for an example), you will see that they don't get checked (i.e., the filtering works).
function checkattempts() {
var inputs = document.getElementsByTagName('INPUT');
inputs = filterByParent(inputs, function(el) {return findParentNode(el, 'FORM');});
for(var i = 0; i < inputs.length; ++i) {
inputs[i].checked = 'checked';
}
}
"Deselect all" would of course be
inputs[i].checked = '';
instead.
Jon