}
}
+/**
+ * Either check, or uncheck, all checkboxes inside the element with id is
+ * @param id the id of the container
+ * @param checked the new state, either '' or 'checked'.
+ */
+function select_all_in_element_with_id(id, checked) {
+ var container = document.getElementById(id);
+ if (!container) {
+ return;
+ }
+ var inputs = container.getElementsByTagName('input');
+ for (var i = 0; i < inputs.length; ++i) {
+ if (inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
+ inputs[i].checked = checked;
+ }
+ }
+}
+
function select_all_in(elTagName, elClass, elId) {
var inputs = document.getElementsByTagName('input');
inputs = filterByParent(inputs, function(el) {return findParentNode(el, elTagName, elClass, elId);});
found.
*/
function findParentNode(el, elName, elClass, elId) {
- while(el.nodeName.toUpperCase() != 'BODY') {
- if(
- (!elName || el.nodeName.toUpperCase() == elName) &&
+ while (el.nodeName.toUpperCase() != 'BODY') {
+ if ((!elName || el.nodeName.toUpperCase() == elName) &&
(!elClass || el.className.indexOf(elClass) != -1) &&
- (!elId || el.id == elId))
- {
+ (!elId || el.id == elId)) {
break;
}
el = el.parentNode;
function filterByParent(elCollection, parentFinder) {
var filteredCollection = [];
- for(var i = 0; i < elCollection.length; ++i) {
+ for (var i = 0; i < elCollection.length; ++i) {
var findParent = parentFinder(elCollection[i]);
- if(findParent.nodeName != 'BODY') {
+ if (findParent.nodeName.toUpperCase != 'BODY') {
filteredCollection.push(elCollection[i]);
}
}