HighDots Forums  

Radio button de-check with onclick?

alt.html.dhtml alt.html.dhtml


Discuss Radio button de-check with onclick? in the alt.html.dhtml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Harry Haller
 
Posts: n/a

Default Radio button de-check with onclick? - 10-29-2006 , 03:28 PM






I have a radio button group. When the page loads none of them are
selected. OnClick selects ONE and clicking another one selects a
different one - this is normal behavior.

I want to modify it so that clicking on a radio which is already
selected will deselect it so that none of the group are selected.

I can get the required behavior with a double-click:

ondblclick="this.checked=!(this.checked);"

or even:

ondblclick="this.checked=false;"

How can I get that behavior with an onclick() - to de-check the
currently checked button?

Reply With Quote
  #2  
Old   
johkar
 
Posts: n/a

Default Re: Radio button de-check with onclick? - 10-29-2006 , 04:02 PM






Harry Haller wrote:
Quote:
I have a radio button group. When the page loads none of them are
selected. OnClick selects ONE and clicking another one selects a
different one - this is normal behavior.

I want to modify it so that clicking on a radio which is already
selected will deselect it so that none of the group are selected.

I can get the required behavior with a double-click:

ondblclick="this.checked=!(this.checked);"

or even:

ondblclick="this.checked=false;"

How can I get that behavior with an onclick() - to de-check the
currently checked button?
You are asking how to change a radio button to behave like a checkbox.
This isn't a good idea as that is not what people's mental model of
radio button behavior is. Please consider adding one more radio
button with a label of 'None' or something similar. You can even
default it as 'checked'. This allows the user to select a radio button
from the group while still allowing them to indicate that it was a
mistake and choose 'nothing'.

John



Reply With Quote
  #3  
Old   
Harry Haller
 
Posts: n/a

Default Re: Radio button de-check with onclick? - 10-29-2006 , 09:58 PM



On 29 Oct 2006 14:02:01 -0800, "johkar" <nosendjunk (AT) msn (DOT) com> wrote:

Quote:
Harry Haller wrote:
I have a radio button group. When the page loads none of them are
selected. OnClick selects ONE and clicking another one selects a
different one - this is normal behavior.

I want to modify it so that clicking on a radio which is already
selected will deselect it so that none of the group are selected.

I can get the required behavior with a double-click:

ondblclick="this.checked=!(this.checked);"

or even:

ondblclick="this.checked=false;"

How can I get that behavior with an onclick() - to de-check the
currently checked button?

You are asking how to change a radio button to behave like a checkbox.
This isn't a good idea as that is not what people's mental model of
radio button behavior is. Please consider adding one more radio
button with a label of 'None' or something similar. You can even
default it as 'checked'. This allows the user to select a radio button
from the group while still allowing them to indicate that it was a
mistake and choose 'nothing'.

John
My sentiments too. But I code the site - I don't write the spec. My
manager does and he hasn't read books on "Designing the user
interface", etc. ... He is very hands on - doesn't like me taking the
laptop home, wants me to work exclusively from the office. The
previous designer wrote the pages like that - right now WHEN NOTHING
IS SELECTED - the system logically selects everything in that group -
so when no radio is selected - all 6 of them must be selected in the
form.

I agree with you - it should be a checkbox group with either all or
only 1 selected!

But..., out of interest - how do I go about modifying the click
button? - can I override the event or add a supplementary event
handler?

I will tell the boss (again) what I think the page should be doing.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.