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
> 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?
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 On May 7, 2:55 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> 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). > > > 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?
On Thu, May 7, 2009 at 2:22 PM, zambezi <b.butler-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 <INPUT> 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". </quote> If you want a "no preference" option, you should provide one explicitly. FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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 Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, May 7, 2009 at 2:22 PM, zambezi <b.but...-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 <INPUT> 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". > </quote> > > If you want a "no preference" option, you should provide one explicitly. > > FWIW, > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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 On May 7, 6:31 pm, "E. Litwin" <elit...-ur4TIblo6goN+BqQ9rBEUg@public.gmane.org> wrote:> 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 Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > On Thu, May 7, 2009 at 2:22 PM, zambezi <b.but...-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 <INPUT> 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". > > </quote> > > > If you want a "no preference" option, you should provide one explicitly. > > > FWIW, > > -- > > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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.
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 Vargo <AJVargo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > 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. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, May 7, 2009 at 7:03 PM, zambezi <b.butler-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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 Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, May 7, 2009 at 7:03 PM, zambezi <b.but...-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
On Fri, May 8, 2009 at 9:37 AM, zambezi <b.butler-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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 :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
On May 7, 12:46 pm, zambezi <b.but...-GrTI0ftTvuWGJGYlWa3Ukdi2O/JbrIOy@public.gmane.org> 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.
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
Stan Kaufman 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
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. -- Posted via http://www.ruby-forum.com/.
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