Radio button selection in jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanmukhi
    New Member
    • Jan 2007
    • 58

    #1

    Radio button selection in jsp

    Hi All,

    how to control the selection of radio buttons in jsp.
    i think i have to write java script for that..
    my code is like this
    Code:
    <form name="form1">
    <input type="radio" name="male">Male
    <input type="radio" name="female">Female
    <input type="submit" value="submit">
    </form>
    my problem is
    if i select one radio button then i am not able to deselect it and
    i am not able to select only one radio button.
    how can i achieve it by using java script.

    can anybody help me?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by shanmukhi
    Hi All,

    how to control the selection of radio buttons in jsp.
    i think i have to write java script for that..
    my code is like this
    Code:
    <form name="form1">
    <input type="radio" name="male">Male
    <input type="radio" name="female">Female
    <input type="submit" value="submit">
    </form>
    my problem is
    if i select one radio button then i am not able to deselect it and
    i am not able to select only one radio button.
    how can i achieve it by using java script.

    can anybody help me?
    I thought that default behaviour is that you can only deselect a radio button by
    selecting another radio button. If I remember well you can preselect a radio
    button using the "selected" flag in it's tag.

    You don't need Javascript for that; simply make your JSP generate the
    appropriate html and you're in bizniz ;-)

    kind regards,

    Jos

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      Originally posted by shanmukhi
      Hi All,

      how to control the selection of radio buttons in jsp.
      i think i have to write java script for that..
      my code is like this
      Code:
      <form name="form1">
      <input type="radio" name="male">Male
      <input type="radio" name="female">Female
      <input type="submit" value="submit">
      </form>
      my problem is
      if i select one radio button then i am not able to deselect it and
      i am not able to select only one radio button.
      how can i achieve it by using java script.

      can anybody help me?
      give them the same name:
      [HTML]
      <form name="form1">
      <input type="radio" name="gender">M ale
      <input type="radio" name="gender">F emale
      <input type="submit" value="submit">
      </form>
      [/HTML]

      good luck

      Comment

      • shanmukhi
        New Member
        • Jan 2007
        • 58

        #4
        Originally posted by epots9
        give them the same name:
        [HTML]
        <form name="form1">
        <input type="radio" name="gender">M ale
        <input type="radio" name="gender">F emale
        <input type="submit" value="submit">
        </form>
        [/HTML]

        good luck
        it's working fine now..
        thank u

        Comment

        Working...