jQuery: How to handle radio buttons

Posted on: Jul 03, 2008 by wenbert

Here is a quick tutorial on how to handle radion buttons using jQuery.

< input type="radio" name="empType" value="regular" /> Regular
< input type="radio" name="empType" value="temporary" /> Temporary

Then the jQuery code: (assuming that you have already included the JS file in the header…)

 $("input[@name='empType']").change(
        function() {
            if ($("input[@name='empType']:checked").val()) {
                alert($("input[@name='empType']:checked").val());
            }
        }
    );

Subscribe to comments Comment | Trackback |
Post Tags: ,

Browse Timeline


Comments ( 5 )

Too bad i didnt come across this blog before. Great stuff you got here. Thanks.

Psychic Advice added these pithy words on Jul 12 08 at 9:55 PM

Hey I just wanted to tell about my website, UptMon.
It’s a tool for monitoring up- and response time for everything from websites to voice-over-IP services.
The user can choose to receive reports in case of failures, and much more!

The address is: http://uptmon.sytes.net

And it’s completely free!

//Alex

Alex added these pithy words on Jul 14 08 at 6:24 AM

Nice post, you got some good points there – thank you.

Import from China added these pithy words on Jul 20 08 at 3:51 AM

Thanks for sharing!

Web Development Manila added these pithy words on Feb 14 09 at 10:15 AM

if my field name is data[user][myradio], how to handle this?

Thanks

Musa added these pithy words on Apr 09 10 at 6:49 PM

Add a Comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


© Copyright 2007 eKini Web Developer Blog . Thanks for visiting!