How to obtain the value of the selected radio button

Here is a simple way to get the value for the selected button in an html form, using jquery:

<form>
<input type=”radio” name=”status” value=”1″ /> Free <br />
<input type=”radio” name=”status” value=”2″ selected /> Reserved <br />
<input type=”radio” name=”status” value=”3″ /> Not available <br />
</form>

 var x = $(‘input[name=status]:checked’).val();

x will now contain 2.

About Gaston

MCT, MCSD, MCDBA, MCSE, MS Specialist
This entry was posted in Development and tagged , , . Bookmark the permalink.

4 Responses to How to obtain the value of the selected radio button

  1. blog says:

    I couldn’t refrain from commenting. Perfectly written!

    Like

  2. Thanks for sharing your thoughts. I truly appreciate
    your efforts and I am waiting for your further post thank you once again.

    Like

  3. I’m gone to inform my little brother, that he should also pay a quick visit this website on regular basis to obtain updated from latest news.

    Like

Leave a Reply to 비트코인배팅 Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s