Need help with this select all checkboxes code...

wxdqz

New Member
I can't seem to get this code to work quite right.

------------------------------
the function (works fine)
------------------------------
<script language=javascript>
<!--
function SomeJSFunction(oDiv,doit){
var curobj = eval(oDiv+'.children')
i=0
while(i<curobj.length){
if(curobj.type=="checkbox"){
curobj.checked=doit
}
i++
}
}
-->
</script>
------------------------------------

when i use the function with the checkboxes nested within only a <DIV> tag... it works correctly.
Unfortunately the code i need to apply this to uses tables and it doesn't work properly.

--------------
Works
--------------
<div ID='Div3'>
<input type=checkbox name=selected_mail value='http://www.webdeveloper.com/forum/archive/index.php/checkall' onclick=SomeJSFunction(this.parentElement.id,this.checked)>
<input type=checkbox name=selected_mail[] value=http://www.webdeveloper.com/forum/archive/index.php/132><input type=checkbox name=selected_mail[] value=131><input type=checkbox name=selected_mail[] value=130><input type=checkbox name=selected_mail[] value=129><input type=checkbox name=selected_mail[] value=128><input type=checkbox name=selected_mail[] value=127><input type=checkbox name=selected_mail[] value=126>
</div>

---------------------------
Code I need to work
---------------------------

<div ID='Div3'>
<table>
<TR>
<td align=center>
<input type=checkbox name=selected_mail value='http://www.webdeveloper.com/forum/archive/index.php/checkall' onclick=SomeJSFunction(this.parentElement.id,this.checked)></td>
</TR>
<TR><td align=center><input type=checkbox name=selected_mail value=http://www.webdeveloper.com/forum/archive/index.php/></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr><TR><td align=center><input type=checkbox name=selected_mail value=></td></tr> </table>
</div>

------------------

Any ideas???? thx
 
Back
Top