doubleclick a radio button to remove selection

We needed to set up a group of radio buttons so that when any of them is doubleclicked any selection in the group is removed. . The following javascript snippet sets up the function kp() which removes all selections upon a doubleclick:




<script type="text/javascript">
 
function kp() {
    var rb = document.getElementsByName('rb');
    for( var i=0; i < rb.length; i++) {
         rb[i].checked = false;
    }
}
 

And the corresponding html which calls kp():

<input name="rb" value="0" type="radio" ondblclick="kp()"/>No
<input name="rb" value="1" type="radio" ondblclick="kp()"/>Yes
<input name="rb" value="3" type="radio" ondblclick="kp()"/>Maybe
<input name="rb" value="4" type="radio" ondblclick="kp()"/>Rather Not

Leave a Comment

You must be logged in to post a comment.