SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Radio button queries

    Gudday all
    I would like to have a form with radio buttons and some text boxes and have some questions
    Code:
    <form name="catalogueDetails" method="post" action=""> 
     <input type="radio" checked="checked" name="printed" value="printed" />Printed version
     <span style="margin-right:45px;"></span>
     <input type="radio" name="cd" value="cd" />CD version<br /><br />
     <label>Name*:</label><input name="name" type="text" size="30" />
     <br /><br />
     <label>Address*:</label><input name="address" type="text" size="30" />
     <br /><br />
     <label>City/Town*:</label><input name="city" type="text" size="30" />
     <br /><br />
     <label>State*:</label><input name="state" type="text" size="30" />
     <br /><br />
     <label>Post code*:</label><input name="postcode" type="text" size="30" />
     <input type="submit" value="Order Catalogue">
    </form>
    1. Is it possible to combine radio buttons and text boxes in the same form?
    2. By default the radio button is printed version yet it allows me to choose the cd version as well i.e. I can have both buttons selected simultaneously. I thought that this was not allowable?
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. What exactly do you mean? You can have as many radio buttons as you want in each form...

    2. You need to name the radio buttons the same name if you want to choose between them and not be able to select both. For example:

    Code:
    <input type="radio" name="yesno" value="yes">Yes
    <input type="radio" name="yesno" value="no">No
    This way, the user can only have one of the two selected at a time. However, if they have different names, the user can select them both at the same time. So try changing your code to this:

    Code:
    <input type="radio" checked="checked" name="medium" value="printed" />Printed version
     <span style="margin-right:45px;"></span>
     <input type="radio" name="medium" value="cd" />CD version<br /><br />
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Possibility
    Thank you for your prompt reply.
    Quote Originally Posted by Possibility View Post
    1. What exactly do you mean? You can have as many radio buttons as you want in each form...
    I was a little unclear. What I meant can I combine radio buttons and text entry areas within the same
    <form>
    ...
    </form>?
    Quote Originally Posted by Possibility View Post
    2. You need to name the radio buttons the same name if you want to choose between them and not be able to select both. For example:

    Code:
    <input type="radio" name="yesno" value="yes">Yes
    <input type="radio" name="yesno" value="no">No
    This way, the user can only have one of the two selected at a time. However, if they have different names, the user can select them both at the same time. So try changing your code to this:

    Code:
    <input type="radio" checked="checked" name="medium" value="printed" />Printed version
     <span style="margin-right:45px;"></span>
     <input type="radio" name="medium" value="cd" />CD version<br /><br />
    Thank you for that answer. I was close but not close enough.
    ========================
    Carn the Tiges!
    www.petalsandpatches.com

  4. #4
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was a little unclear. What I meant can I combine radio buttons and text entry areas within the same
    <form>
    ...
    </form>?
    I'm still not understanding exactly what you're getting at. You can have as many as any type of input in a single form as you want - radio buttons, check boxes, input lines, text areas, files, etc..
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  5. #5
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You can't have both a checkbox and a radiobutton for the same form control. That would defeat the purpose of radiobuttons. Also, radiobuttons and checkboxes are different things; a checkbox is either yes or no, a radiobutton is a choice between multiple options.

    You can of course combine the two elements, but they will have to have different names.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!


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
  •