Automatically select specific checkboxes on clicking a radio button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • leifstarkey
    New Member
    • Mar 2008
    • 1

    Automatically select specific checkboxes on clicking a radio button

    Hi all...

    My problem is I'm trying to make a form containing radio buttons and checkboxes. But on the event that one of the radio buttons is selected i want specific checkboxes to then be automatically selected.

    E.g.
    "On the event that gender male (radiobutton) is selected - for the form to then automatically select the following film genre (checkboxes) Action, Sci-Fi and Crime and leave unselected the remaining checkboxes."

    Gender: >Male >Female


    Film Genres:
    Action[ / ] Romance[ ] Sci-Fi[ / ]
    Musical[ ] Crime[ / ] Disney[ ]



    If anyone can suggest how i would go about achiveing this; i would be truely grateful.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by leifstarkey
    Hi all...

    My problem is I'm trying to make a form containing radio buttons and checkboxes. But on the event that one of the radio buttons is selected i want specific checkboxes to then be automatically selected.

    E.g.
    "On the event that gender male (radiobutton) is selected - for the form to then automatically select the following film genre (checkboxes) Action, Sci-Fi and Crime and leave unselected the remaining checkboxes."

    Gender: >Male >Female


    Film Genres:
    Action[ / ] Romance[ ] Sci-Fi[ / ]
    Musical[ ] Crime[ / ] Disney[ ]



    If anyone can suggest how i would go about achiveing this; i would be truely grateful.
    Unfortunately you've posted in the 'feedback' forum.
    You might want to try the javascript forum :P

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by leifstarkey
      My problem is I'm trying to make a form containing radio buttons and checkboxes. But on the event that one of the radio buttons is selected i want specific checkboxes to then be automatically selected.
      Call a function onclick (radio buttons) which checks the checkboxes, e.g.
      [code=javascript]var checkboxes = document.getEle mentsByName(che ckboxesName);
      for (i=0; i < checkboxes.leng th; i++) {
      if (checkboxes[i].value == "Sci-Fi") checkboxes[i].checked = true;
      ...
      }[/code]

      Ps. changed thread title to better describe the question.

      Comment

      Working...