View Full Version : Check boxes with same ID

06-23-2009, 07:44 PM
Hi Guys,

I'm hoping some guru out there can help me.. I'm looking for a javascript which will check all boxes with the same id if one is checked.. For instance:

Box 1 id=this
Box 2 id=this
Box 3 id=that
Box 4 id=that

If I click Box 1, it should also check box 2.. If I uncheck box 1 it should also uncheck box 2...I have to do it by id instead of name and cannot seem to get it to work.. These are input flags with type=checkbox....

Please help....


06-23-2009, 08:29 PM
Among many versions, this is one:
See: http://www.webdeveloper.com/forum/showthread.php?t=37122&highlight=checkboxes+multiple

06-23-2009, 08:47 PM
IDs should be unique on a page. In other words, you shouldn't have multiple elements with the same ID. Browsers will still work (probably), but may behave inconsistently.

06-23-2009, 09:42 PM
I changed id= to class= and implemented the script and it is working well..

Thanks guys!


06-24-2009, 02:24 AM
You're most welcome.
I'm glad we were able to help.
Good Luck!