jewishj
03-31-2005, 03:02 AM
I am using the following functions to check checkboxes...
//this is the checkAll function for the checkbox to toggle checked/unchecked
function checkAll(checkboxID){
state=(document.getElementById(checkboxID).checked==false) ? false :true;
i=1;
while(document.getElementById(checkboxID+i)!=false){
document.getElementById(checkboxID+i).checked=state;
i++;
}
}
//this is for the check all links
function checkAllFromLink(checkboxID,state){
i=0;
while(document.getElementById(checkboxID+i)!=false){
document.getElementById(checkboxID+i).checked=state;
i++;
}
}
The first is accessed via a checkbox with an id like "blah" where the set of checkboxes have ids like "blah1" "blah2" "blah3" etc.
A small example of html to access this function:
<input type="checkbox" id="blah" onclick="checkAll('blah')" />
<input type="checkbox" id="blah1" />
<input type="checkbox" id="blah2" />
<input type="checkbox" id="blah3" />
The second is accessed via a link that passes the id of the set of checkboxes (ids work the same as the first) and the state to change the checkbox to.
A small example of html to access this function:
<a href="javascript:checkAllFromLink('blah',true)">Check All</a>
<a href="javascript:checkAllFromLink('blah',false)">Uncheck All</a>
<input type="checkbox" id="blah1" />
<input type="checkbox" id="blah2" />
<input type="checkbox" id="blah3" />
The functions work but still produce errors: "document.getElementById(...) is null or not an object." I cannot reference the checkboxes by name because the names have to be in the form of arrays for submittal.
Thanks for any help with this issue
//this is the checkAll function for the checkbox to toggle checked/unchecked
function checkAll(checkboxID){
state=(document.getElementById(checkboxID).checked==false) ? false :true;
i=1;
while(document.getElementById(checkboxID+i)!=false){
document.getElementById(checkboxID+i).checked=state;
i++;
}
}
//this is for the check all links
function checkAllFromLink(checkboxID,state){
i=0;
while(document.getElementById(checkboxID+i)!=false){
document.getElementById(checkboxID+i).checked=state;
i++;
}
}
The first is accessed via a checkbox with an id like "blah" where the set of checkboxes have ids like "blah1" "blah2" "blah3" etc.
A small example of html to access this function:
<input type="checkbox" id="blah" onclick="checkAll('blah')" />
<input type="checkbox" id="blah1" />
<input type="checkbox" id="blah2" />
<input type="checkbox" id="blah3" />
The second is accessed via a link that passes the id of the set of checkboxes (ids work the same as the first) and the state to change the checkbox to.
A small example of html to access this function:
<a href="javascript:checkAllFromLink('blah',true)">Check All</a>
<a href="javascript:checkAllFromLink('blah',false)">Uncheck All</a>
<input type="checkbox" id="blah1" />
<input type="checkbox" id="blah2" />
<input type="checkbox" id="blah3" />
The functions work but still produce errors: "document.getElementById(...) is null or not an object." I cannot reference the checkboxes by name because the names have to be in the form of arrays for submittal.
Thanks for any help with this issue