...

View Full Version : Radio button with no default



shnplr
10-23-2010, 08:51 AM
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?



<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,

Mad_Designer
10-26-2010, 11:35 AM
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:

<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 :-)

getbestproduct
10-27-2010, 03:56 AM
you don't really need the span to hide the extra radio button.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum