SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Radio Button Parameters

    Hi,

    I am new to HTML/CSS and such.

    I designed an XHTML form. There is a section in it with a radio button, here is the code:

    Code:
    <p>
          Sex:
    </p>
    <div>
          <label for="sexMaleRadio" class="fixedwidthText">Male:</label>
          <input name="sexRadio" id="sexMaleRadio" type="radio"   checked="checked"/>
    </div>
    <div>
          <label for="sexFemaleRadio" class="fixedwidthText">Female:</label>
          <input name="sexRadio" id="sexFemaleRadio" type="radio"/>
    </div>
    When I inspect the URL parameters after mock-submitting this form here is what I get for the radio button:

    Code:
    sexRadio=on
    regardless of which radio button of the two I select.
    Here is the question: If I want to extract the parameter programmaticaly on the back end, how would I know which of the two (or more) radio buttons was checked, if they all share the same?

    Could anyone please suggest?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must specify a value attribute for each radio button. It's required for checkboxes and radio buttons. Then, upon submission, the value of the selected button will be passed in the sexRadio parameter.

    Code:
    <input name="sexRadio" id="sexMaleRadio" type="radio" value="male" checked="checked"/>
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is perfect. Thanx.


Tags for this Thread

Bookmarks

Posting Permissions

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