I've got a checkbox in an li element. I put an onclick on the li element to toggle the checkbox. This works fine if I am over the li element but not over the checkbox. But if I am over the checkbox the checkbox doesn't change (or it changes twice returning it to the original state). So how do I get this working properly?
Edit: The code below has all the relevant stuff in it I think, but here's a link to the full online version. The checkboxes are in the fourth tab. http://bokehman.com/UI-test/
HTML Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-type" content="text/html;charset=ISO-8859-1"> <script type="text/javascript"> onload = layout function layout() { LIs = document.getElementById('choose').getElementsByTagName('li') for(i=0; i<LIs.length;i++) { LIs[i].onclick=function(){ return toggle(this) } } } function toggle(caller) { caller.firstChild.checked = !caller.firstChild.checked return false } </script> <title></title> </head> <body> <div id="choose"> <ul> <li><input type="checkbox" name="choose[]" value="-1770"> 177.0W NSS 9</li> <li><input type="checkbox" name="choose[]" value="-1390"> 139.0W AMC 8</li> </ul> </div> </body> </html>


Reply With Quote

Bookmarks