i’ve created a couple functions that allow a user to select a checkbox by clicking anywhere in the same table row. It works by parsing an array of <td>s in the row, looking for the checkbox and switching it’s state. Small problem. If the user clicks on the checkbox itself, it selects it and immediately unselects it ? Any suggestions?
[code]if(rows=document.getElementsByTagName(‘TR’)) {
for(x=0; x<rows.length; x++) {
rows[x].onclick=function() {toggleSelect(this)}
}
}
function toggleSelect(row) {
cells=row.getElementsByTagName(‘TD’);
for(y=0; y<cells.length; y++) {
if(checkbox=cells[y].getElementsByTagName(‘INPUT’)[0]) {
if(!checkbox.checked) {
checkbox.checked=true;
} else {
checkbox.checked=false;
}
}
}
}