Triple state radio buttons


#1

Can I coax a pair of radio buttons to consistently maintain their
triple state functionality (null, true, false)?

In others words allow the user to undo a response and return the
control to a null state (nothing selected).

I hope this isn’t coming down to some sort of Javascript workaround.

Thanks much.
Bill


#2

Can I coax a pair of radio buttons to consistently maintain their
triple state functionality (null, true, false)?

In others words allow the user to undo a response and return the
control to a null state (nothing selected).

I hope this isn’t coming down to some sort of Javascript workaround.

I don’t think so. radio button parameters are either

… passed with a value (if clicked)
or
… passed with an empty value or not passed at all (if not clicked)

There’s no way to distinguish b/n unclicked (which would be your false
I assume) and null.

Why not turn them into drop downs with blank/true/false as values?


#3

On Thu, May 7, 2009 at 2:22 PM, zambezi removed_email_address@domain.invalid
wrote:

It appears that some ivory towered radio button designer never
conceived that a user might click on a radio button group, change
their mind and want to undo the click therefore returning to a false-
false state.

Quoting the HTML 4 spec:

If no radio button in a set sharing the same control name is initially
“on”,
user agent behavior for choosing which control is initially “on” is
undefined.
Note. Since existing implementations handle this case differently, the
current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4),
which states:

At all times, exactly one of the radio buttons in a set is checked.
If none of the elements of a set of radio buttons specifies
`CHECKED’, then the user agent must check the first radio button
of the set initially.

Since user agent behavior differs, authors should ensure that in each
set of radio buttons that one is initially “on”.

If you want a “no preference” option, you should provide one explicitly.

FWIW,

Hassan S. ------------------------ removed_email_address@domain.invalid


#4

Thanks for the reply, Philip.

Dropdown boxes are cumbersome visually and ergonomically for the user
and I would rather not go there.

If I have a pair of grouped Ruby generated radio buttons, then
following are the initial possibilities or states:

false - false (in which case presumably a null is returned)
false - true (returns a 0)
true - false (returns a non-zero)

It appears that some ivory towered radio button designer never
conceived that a user might click on a radio button group, change
their mind and want to undo the click therefore returning to a false-
false state. Some languages providing for a user interface have
caught on, some haven’t.

Is it perhaps possible to do this by grouping a couple of checkboxes
and set then them up so that the user can select either one or none??

Thanks again,
Bill
Th


#5

As the previous poster said, provide a “Neither” or “None” option and
have that one be selected as the default when the page loads.
That is much easier for a user to understand as well.

On May 7, 2:28 pm, Hassan S. removed_email_address@domain.invalid


#6

What if you have the third/null value hidden? You can use javascript
for a “clear choice” link or something, which would check the 3,
hidden radio button. It could also be the default for new.


#7

I appreciate the answers and help.

So I added a third radio button to the group. Remember that what I
need is a three state situation (null, true, false). This of course
effectively gives me a quadruple state. So I set the third radio
button’s value to NIL which gets me back to a three state situation…

Now let me provide a little background.
This is being used for a lengthy questionnaire (there are 50+ sets of
questions). In short, part of good questionnaire design requires that
the design doesn’t bias the respondant to particular answers.

So I don’t want the radio button group to show a default value. It
potentially confuses respondants and may bias their input. However
with the above configuration (the third radio button value of NIL),
this becomes the default value and is diplayed to user as checked .
Is there a way to avoid this. If I am going to use a three button
group configuration, I need to have them all unchecked initially.

Thanks,
Bill


#8

On Thu, May 7, 2009 at 7:03 PM, zambezi removed_email_address@domain.invalid
wrote:

… If I am going to use a three button
group configuration, I need to have them all unchecked initially.

And as the W3C spec I quoted indicates, you can’t count on that
if you’re using HTML. Period. If none are explicitly checked by you,
the user agent can check any one it wants as a default. Adding a
third button doesn’t change that.

Perhaps you should explore using something like Flash/Flex for
your interface?


Hassan S. ------------------------ removed_email_address@domain.invalid


#9

You could provide the third button hidden and initially checked. Show
it
with javascript
when one of the other buttons is checked so that the user then has the
option of selecting it again. You could then make it disapear again
when
selected if you wanted to.

Colin

2009/5/8 Andrew V. removed_email_address@domain.invalid


#10

Hi Hassan,

Do you have any idea of what behavior to expect if I explicitly set
each radio button’s checked property to unchecked? What will take
precedence according to W3C specs (or is this all just another browser
war casualty)?

<%= f.radio_button(:hypotonic_saline, nil, :checked =>

“unchecked”) %>

Thanks, Bill

On May 8, 8:58 am, Hassan S. removed_email_address@domain.invalid


#11

On May 7, 12:46 pm, zambezi removed_email_address@domain.invalid wrote:

In others words allow the user to undo a response and return the
control to a null state (nothing selected).

Why not provide an “Clear” button that deselects all the radio buttons
in the group? That’s simple Javascript, and I wouldn’t call it a
“workaround”. It explicitly provides the functionality that you appear
to want – a mechanism for a user to undo a response. Seems like a
much simpler and more deft solution to the problem than trying to
rejigger the semantics of radio buttons.


#12

On Fri, May 8, 2009 at 9:37 AM, zambezi removed_email_address@domain.invalid
wrote:

Do you have any idea of what behavior to expect if I explicitly set
each radio button’s checked property to unchecked?

Again, it’s up to the user-agent how it handles this situation. I’d just
suggest 1) either accepting having a visible “no preference” choice
(and make it visually obvious that it’s a default) or 2) trying what you
suggest and testing thoroughly in all the “standard” browsers.

You’ll have to decide how long that #2 list is for your audience :slight_smile:

HTH,

Hassan S. ------------------------ removed_email_address@domain.invalid


#13

Hmmm… I can use a Javascript solution and assume/hope the worlds’
browsers are all JS enabled. Or use a non-JS solution and assume/hope
the browsers/versions I don’t test for will see things the same way.
Either way I don’t see things degrading nicely.

My bias (rational or otherwise) is against Javascript. But if I
throw in the towel and go that direction, then I think I would
consider creating some sort of checkbox group and use JS to make sure
that only one checkbox per group could be selected.

Cheers, Bill


#14

Stan K. wrote:
[…]

Why not provide an “Clear” button that deselects all the radio buttons
in the group? That’s simple Javascript, and I wouldn’t call it a
“workaround”.

That won’t reliably work. Remember, the spec says that exactly one
radio button is selected at all times. Period. JavaScript will not
(or should not) get around this.

If the options must really be unchecked to start with, the only solution
is not to use radio buttons. However, I’ve also seen surveys that avoid
bias by presenting options in random order. I’m not sure this is a
great solution for your case, but it’s something to consider.

Failing that, I think you need a custom input control implemented with
Flash or JavaScript (check out SproutCore for the latter). HTML just
doesn’t have the feature you need here.

Best,

Marnen Laibow-Koser
http://www.marnen.org
removed_email_address@domain.invalid


#15

A final THANK YOU to all the good folks who took time to reply. Alas,
the suggestions were somewhat unpalatable to me, but at least I am not
still scouring google thinking I have missed some simple alternative.
Sometimes you just can’t get there from here.

I have finally gone with the three radio button option with first
one’s value set to nil and the entire group explicitely set to
unchecked. So far RFC1866 section 8.1.2.4 hasn’t protested about
this breach of propriety and forced a switch in the unchecked status -
at least not in the half dozen browser flavors I’ve tested so far.

Cheers,
Bill


#16

zambezi wrote:

Can I coax a pair of radio buttons to consistently maintain their
triple state functionality (null, true, false)?

In others words allow the user to undo a response and return the
control to a null state (nothing selected).

So I added a third radio button to the group. Remember that what I
need is a three state situation (null, true, false).

So I don’t want the radio button group to show a default value. It
potentially confuses respondants and may bias their input. However
with the above configuration (the third radio button value of NIL),
this becomes the default value and is diplayed to user as checked .
Is there a way to avoid this. If I am going to use a three button
group configuration, I need to have them all unchecked initially.

You are always going to have a default value, even if your default is
neither ‘A’ or ‘B’ - a null state - nothing selected. The only way to
return to a nul state is to choose ‘C’ (label it ‘clear’). So you need 3
radio buttons with the third checked initially.