Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    Sydney, Aust
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Radio button with no default

    Dear experts,

    I want a control which allows zero or one selection from many options. For example on a Declaration page of a web form I ask such question as:

    "Have you had any convictions for other offences?" [yes] [no]"

    In this case I require the user to physically select Yes or No.

    The closet control that fits this specific case is, I think, Radio button; however unlike some other UI's the HTML specification http://www.w3.org/TR/html401/interact/forms.html#radio infers a default option should always be checked.

    In fact most (all?) browsers allow "no default" - and since I doubt it's a bug in all browsers it seems clear to me having no default is considered valid by ui designers - I've read arguments about the "No answer" option however in this case I wish to avoid a 3rd option. I've also no problem being unable to deselect a radio button once selected; this is fine, consistent and desireable behaviour in this case.

    For the requirement of a "zero or one of many" radio control; can I simply add a hidden "default" option?

    Code:
    <input type="radio" name="decl-other" value="true">Yes</input>
    <input type="radio" name="decl-other" value="false">No</input>
    <span id="decl-other-default" style="visibility:hidden;">
    <input type="radio" name="decl-other" value="undefined" checked="checked">&nbsp;</input>
    </span>
    The approach seems to fit both my requirement AND adhere to the spec (which doesn't explicitly state the element must be visible). Would this be a valid solution/workaround?

    Unfortunately, I dont know how to test it! - is anyone aware of a browser which follows the spec and defaults one of the radio buttons...? Is this even an issue or just a moot point?

    Thanks in advance for any comments or insight,

  • #2
    New Coder
    Join Date
    Oct 2010
    Location
    Portsmouth, UK
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post
    Hi Shnplr

    Radio buttons are not the best option if you want them to be able to de-select them i would use check/tick boxes. Radio buttons are perfect for the option if you only want them to either click yes or no and not leave blank.
    if any of that makes sense?

    As for default, on this sort of form i would suggest no default as it could end up being taken as offence or worse being sent through to you as default and being wrong.

    to take of default from what i remember:
    Code:
    <input type="radio" name="decl-other" value="true">Yes</input>
    <input type="radio" name="decl-other" value="false">No</input>
    <span id="decl-other-default" style="visibility:hidden;">
    <input type="radio" name="decl-other" value="undefined" checked="checked">&nbsp;</input>
    </span>
    Delete the following:
    checked="checked"

    hope this is of some help, if not let me know and ill see what i can do :-)

  • #3
    Banned
    Join Date
    Aug 2010
    Location
    everywhere
    Posts
    63
    Thanks
    2
    Thanked 3 Times in 3 Posts
    you don't really need the span to hide the extra radio button.


  •  

    Posting Permissions

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