Buy for hundreds of thousands of mp3 downloads from your favorite artists at everyday low prices. download music, classical music, new releases. download movies, updated daily DVD Movies Download Movies, Download Latest download free dvd movies enjoy dvd movies.

this is how radio buttons should work..

So Andy thinks that radio buttons should turn off when you click on the selected one again… and after playing with this a bit, it’s kind of intuitive…

Pretty cool, eh? To get radio buttons to kind of work like checkboxes, here’s what I had to do..

First, since the onClick event always evaluates a radio button to “checked” when the radio button was unchecked or checked before you clicked (which is a little weird, but I guess it makes sense since any function you call with onClick happens *after* the click, and therefore .checked would evaluate to true) — anyway, I put an onFocus to set the “ischecked” variable, and then used that to determine whether or not to turn the radio button back off…

so, add:
onFocus="javascript:woop(this);" onClick="javascript:woot(this);"
to all the radio buttons… and then add the javascript functions:


function woop(radiobutton) {
ischecked = radiobutton.checked;
}

function woot(radiobutton) {
if (ischecked) {
radiobutton.checked = false;
ischecked = false;
} else {
ischecked = true;
}
}

W00t! Maybe there’s a simpler way to do this, and if there is, lemme know. Happy Geeky Friday.

4 Responses to “this is how radio buttons should work..”

  1. andy Says:

    doesn’t work in safari.

  2. Julia Says:

    hmm next time i’m a on safari…i’ll make sure not to pack those radio buttons.

  3. Brian Says:

    function woot(radiobutton) {

    radiobutton.checked = !ischecked;
    ischecked = !ischecked;
    }

    Not sure which is more efficient. Thoughts?

    Thanks for the mind-candy!

  4. dennis Says:

    Sure.. i think yours works too, and yes, less lines, but it’s a little hard to read, imho.. i’m dumb and i like my logic spelt out for me.. :-)

Leave a Reply