Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Check boxes with same ID

    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....

    Thanks,
    Mark

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,065
    Thanks
    36
    Thanked 497 Times in 491 Posts
    Among many versions, this is one:
    See: http://www.webdeveloper.com/forum/sh...boxes+multiple

  • #3
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    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.
    Are you a Help Vampire?

  • #4
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I changed id= to class= and implemented the script and it is working well..

    Thanks guys!

    Mark

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,065
    Thanks
    36
    Thanked 497 Times in 491 Posts
    You're most welcome.
    I'm glad we were able to help.
    Good Luck!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •