Radio's

Discussion in 'HTML' started by Samuël van Laere, Dec 5, 2004.

  1. Could someone explain me why the radio buttons are both selected when
    clicking them??
    Yeah I do something wrong here and have tried combinations but to no avail.
    Thanks.

    <p>Wil je een copie van je bericht ontvangen?<br>
    <input class="input" type="radio" title="Ja ik wil een copie ontvangen"
    name="Ja" id="Ja" value="1">
    <label for="Ja">&nbsp;Ja stuur mij een copie</label>
    <br>
    <input class="input" type="radio" title="Nee ik wil geen copie ontvangen"
    name="Nee" id="Nee" value="0">
    <label for="Nee">&nbsp;Nee stuur mij geen copie</label>
    <br>
    </p>

    Regards,
    Samuël van Laere
    the Netherlands
     
    Samuël van Laere, Dec 5, 2004
    #1
    1. Advertising

  2. "Samuël van Laere" <> wrote:

    > Could someone explain me why the radio buttons are both selected when
    > clicking them??


    On which browser(s), for which specific URL?

    > <input class="input" type="radio" title="Ja ik wil een copie ontvangen"
    > name="Ja" id="Ja" value="1">
    > <label for="Ja">&nbsp;Ja stuur mij een copie</label>
    > <br>
    > <input class="input" type="radio" title="Nee ik wil geen copie
    > ontvangen" name="Nee" id="Nee" value="0">
    > <label for="Nee">&nbsp;Nee stuur mij geen copie</label>


    In that code fragment, you have two radio buttons with different names.
    They act independently of each other. A lone radio button is a really poor
    lonesome button, since a) it is browser-dependent what happens if the user
    does not click on it (a browser might treat it as initially checked) and
    b) once clicked on, there's no normal way to change one's mind about it.

    I guess what has happened is that you have clicked on one of them, then on
    another, and this checks it without unchecking the other. But this is how
    things _should_ be by HTML specifications. If you want to make them belong
    together, the name="..." attributes must be the same. If you do that, you
    should make one of the alternatives (probably the negative one) initially
    checked.

    On the other hand, a checkbox would be more natural for an on/off choice:

    <input class="input" type="checkbox" name="copie" id="Ja" value="1">
    <label for="Ja">&nbsp;Stuur mij een copie</label>

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Dec 5, 2004
    #2
    1. Advertising

  3. "Jukka K. Korpela" <> wrote in message
    news:Xns95B71016211Ejkorpelacstutfi@193.229.0.31...
    >
    > In that code fragment, you have two radio buttons with different names.
    > They act independently of each other. A lone radio button is a really poor
    > lonesome button, since a) it is browser-dependent what happens if the user
    > does not click on it (a browser might treat it as initially checked) and
    > b) once clicked on, there's no normal way to change one's mind about it.
    >
    > I guess what has happened is that you have clicked on one of them, then on
    > another, and this checks it without unchecking the other. But this is how
    > things _should_ be by HTML specifications. If you want to make them belong
    > together, the name="..." attributes must be the same. If you do that, you
    > should make one of the alternatives (probably the negative one) initially
    > checked.
    >
    > On the other hand, a checkbox would be more natural for an on/off choice:
    >
    > <input class="input" type="checkbox" name="copie" id="Ja" value="1">
    > <label for="Ja">&nbsp;Stuur mij een copie</label>
    >


    Indeed I wanted the radio button to uncheck on clicking a different one,
    it never occured to me that it is in the specification, let alone visit the
    source :)
    But i've used a checkbox now, its a whole lot better anyhow since I only
    need to keep track of one value.
    Thanks for clearing the air Yucca.


    Regards,
    Samuël van Laere
    the Netherlands
     
    Samuël van Laere, Dec 6, 2004
    #3
  4. Samuël van Laere

    Toby Inkster Guest

    Samuël van Laere wrote:

    > Could someone explain me why the radio buttons are both selected when
    > clicking them??


    They have different values for the name attribute. Give them a common name.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Dec 6, 2004
    #4
  5. On Sun, 05 Dec 2004 23:37:49 +0000, Jukka K. Korpela wrote:

    > On the other hand, a checkbox would be more natural for an on/off choice:
    >
    > <input class="input" type="checkbox" name="copie" id="Ja" value="1">
    > <label for="Ja">&nbsp;Stuur mij een copie</label>


    Unless the items are mutually exclusive

    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Dec 6, 2004
    #5
  6. Samuël van Laere

    Neal Guest

    Jeffrey:
    > Jukka:
    >> On the other hand, a checkbox would be more natural for an on/off
    >> choice:

    > Unless the items are mutually exclusive


    True, but then it wouldn't be an on-off choice. If it's a multiple-choice,
    radio buttons with the same name is best. If it's a yes/no, checkbox is
    best.

    In fact, radio buttons and select boxes serve a similar end - choosing one
    option from a list. IMO radio buttons are more useful when there's a small
    number of more detailed choices, and select box is best for a longer (but
    not too long!) list of shorter choices.
     
    Neal, Dec 6, 2004
    #6
  7. On Mon, 06 Dec 2004 11:43:16 -0500, Neal wrote:

    > In fact, radio buttons and select boxes serve a similar end - choosing one
    > option from a list. IMO radio buttons are more useful when there's a small
    > number of more detailed choices, and select box is best for a longer (but
    > not too long!) list of shorter choices.


    Huh? "select" box or "check" box?

    select box (i.e. drop-down selector) and radio button are equivalent.

    radio button and CHECK box are not.

    Select box and check box are not.

    check box and multi-select box are equivalent.

    To make it even more clear (and I know you know this, Neal, but this is
    for the benefit of others who might not and also to boost my alt.html
    stats at the end of this week):

    <input type="radio"> is equivalent to <select><option>...</option></select>

    and

    <input type="checkbox"> is quivalent to
    <select MULTIPLE><option>...</option></select>

    later...



    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Dec 6, 2004
    #7
  8. Samuël van Laere

    Neal Guest

    Jeffrey Silverman:

    > Huh? "select" box or "check" box?


    Select. Like I said.

    > check box and multi-select box are equivalent.


    This is true. I didn't mention that. However, I rarely encounter multiple
    select boxes. Nor do I use them, I'd think they'd be confusing to the user
    more often than not.

    Thanks for having me as a guest on the Jeffrey Silverman show. ;)
     
    Neal, Dec 6, 2004
    #8
  9. On Mon, 06 Dec 2004 12:13:07 -0500, Neal wrote:

    >> Huh? "select" box or "check" box?

    >
    > Select. Like I said.


    Right, but my point is just that "select" boxes were not mentioned in this
    post until you broguht them up.

    --
    Jeffrey D. Silverman |
    Website | http://www.newtnotes.com

    Drop "PANTS" to reply by email
     
    Jeffrey Silverman, Dec 6, 2004
    #9
  10. Samuël van Laere

    Neal Guest

    Jeffrey:

    > Right, but my point is just that "select" boxes were not mentioned in
    > this
    > post until you broguht them up.


    That's also correct. I just added that as an aside, to illustrate to the
    uninitiated how the various form controls match up to one another. Seemed
    a shame to discuss radio and check without also mentioning select. It
    might feel left out, and cry.
     
    Neal, Dec 6, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Akin Seigmund Walter-Johnson III

    Help Data bindings with Radio Buttons

    Akin Seigmund Walter-Johnson III, Feb 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    393
    Akin Seigmund Walter-Johnson III
    Feb 26, 2004
  2. Stephen

    radio button list

    Stephen, Jul 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    437
    JohnFol
    Jul 27, 2004
  3. Scott D Johnson
    Replies:
    1
    Views:
    1,075
    Scott D Johnson
    Sep 27, 2006
  4. Jan C. Faerber
    Replies:
    0
    Views:
    623
    Jan C. Faerber
    Jun 30, 2009
  5. Hiten
    Replies:
    1
    Views:
    626
    Vidar Petursson
    May 26, 2004
Loading...

Share This Page