Wednesday, December 30, 2009

Re: [jQuery] If radio button checked - do stuff

You have some redundancy there. Selecting on ':radio' is unnecessary
because you're also selecting for the element name. And the ':checked'
is no good because that limits this to elements that have already been
checked. That's likely not the desired behaviour. Try:

$('form input[name=setting1]').click(function() { ... });


On Wed, Dec 30, 2009 at 11:03 AM, Silver <8800gtsoc@gmail.com> wrote:
> Hey all,
>
> I think I'm close, but I keep getting the errors ( Unkonw pseude-class
> or pseude-elmemt 'radio').
>
> All I need is if the user clicks a radio button for the right if
> statement to run and send the variables to the dq_process php file.
>
> $("form input[name=setting1]:radio").filter(':checked').click(function
> () {
>    if ( $(this).val() == 'home_fy' )
>            $.post("dq_process.php", { q: 1, r: 13300 } );
>    else if ( $(this).val() == 'home_by' )
>            $.post("dq_process.php", { q: 1, r: 24400 } );
>    else
>            $.post("dq_process.php", { q: 1, r: 00000 } );
> });
>
>
> <ol class="answers">
>                <li><input type="radio" name="setting1" value="home_fy"  /> Home –
> front yard</li>
>                <li><input type="radio" name="setting1"
> value="home_by"  /> Home – back yard</li>
>                <li><input type="radio" name="setting1"
> value="cottage"  /> Cottage</li>
> </ol>
>
> Any help would be great. Thanks
>
>
>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate