![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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? |
#3
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |