I guess we posted at the same time. I was initially confused thinking
that your one line needed to be in a loop, but I see now that it
doesn't and that I could get by with

function uncheckRadio(obj) {
        $('input[name="' + obj.name + '"]').attr('checked', false);
}

On Jan 8, 9:17 am, Eric Garside <gars...@gmail.com> wrote:
> > And if the same page contains INPUT elements with the same name either
> > inside another form or outside of any form?

> Then you made a poorly coded page. :P The only reason to have a "name"
> is so you can do something with the form data after submitting it. I
> assumed he was going to key off the name. Using the name isn't really
> a good idea. Like, ever. But he didn't ask how to recode his page, he
> asked how to rewrite his function using jQuery mentality. Which I did.

I am a jq noob not a TOTAL noob.

> Oh, absolutely. To be honest, the best way to do this is to not use
> names at all, but make use of IDs. And, never, ever use inline events.
> Here is the current HTML:

Never, Ever?????

> <input type="radio" ondblclick="javascript:uncheckRadio(this);"
> name="<
> %=variable%>" value="1" >
> <input type="radio" ondblclick="javascript:uncheckRadio(this);"
> name="<
> %=variable%>" value="2" >
>
> This should go to:
>
> <input type="radio" name="<%variable%>" class="unclick" value="1">
> <input type="radio" name="<%variable%>" class="unclick" value="2">
>
> Now, I'm not sure what your goal is here. Is it to have any radio
> button on the page uncheck when you double click it? If so:

Yes any radio button should be able to be un-selected. I don't need
anything special in the class "unclick" do I ? It is only if I want to
have a more restrictive selector like you state below?

> $(':radio').dblclick(function(){
>     $(this).attr('clicked', false);
>
> });
>
> Is all the code you need. If you only want a select few radio buttons
> to have this functionality, use a more restrictive selector.
>
> $('.unclick:radio').dblclick(function(){
>     $(this).attr('clicked', false);
>
> });

Reply via email to