PDA

View Full Version : Convert checkall checkbox to checkall button


MRGTB
06-07-2007, 05:05 PM
In my hack I'm using a checkall CHECKBBOX to select and unselect other checkboxes boxes (put tick in and out of them). But I want to remove that checkbox and instead use a BUTTON that when clicked, will do the same thing. tick and untick the other checkboxes.



Here is my javascript code to look at how its configured.





function em_size(str) {

var a = document.getElementsByName(str);

var n = a.length;

try {

var input_checkall = document.getElementById("checkall_"+str);

var size = 0;

input_checkall.checked = true ;

for (var i=0; i < n; i++) {

if (a[i].checked) {

var piecesArray = a[i].value.split( "|" );

size += piecesArray[3]*1;

} else {

input_checkall.checked = false;

}





And here is the checkall/uncheck "checkbox" code I want converting over to a button instead that does the same thing. Checking/unchecking the other checkboxes





<tr align="left" class="alt2"><td width="80%" align="left"><input type="checkbox" id="checkall_ed2k$rand" onclick="checkAll('ed2k$rand',this.checked)" checked="checked" />&nbsp;<label for="checkall_ed2k$rand"></label>Check all - Uncheck all</td>





Anybody got any ideas on converting this, becuase I can't seem to get it to work and I've been trying all day. I could really do with some help on this one.