A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

jQuery: How to handle radio buttons

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());
            }
        }
    );
This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to jQuery: How to handle radio buttons

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

  2. Alex says:

    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

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

  4. Musa says:

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

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>