jaymc Posted July 22, 2007 Share Posted July 22, 2007 I want to be able to click anywhere in a <TD> to select or unselect a checkbox Here is some code Ive through together, it checks it but doesnt unselect OnClick="if(document.getElementsByName('list').checked='false'){document.getElementsByName('list').checked='true'} else if(document.getElementsByName('list').checked='true'){document.getElementsByName('list').checked='false'} Also, is there a better way in javascript to do this, at the moment Ive got this in every <TD> that has a checkbox Thanks Quote Link to comment https://forums.phpfreaks.com/topic/61274-checkbox/ Share on other sites More sharing options...
jaymc Posted July 23, 2007 Author Share Posted July 23, 2007 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/61274-checkbox/#findComment-305438 Share on other sites More sharing options...
nogray Posted July 23, 2007 Share Posted July 23, 2007 you can use this document.getElementsByName('list').checked = !document.getElementsByName('list').checked; or you can set a function to do to work by calling it with the id paramters onclick="check_box('list');" Quote Link to comment https://forums.phpfreaks.com/topic/61274-checkbox/#findComment-305643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.