Solved

how to retrieve value of radio button sets by class

Posted on 2011-09-15
4
260 Views
Last Modified: 2012-05-12
I have a series of radio buttons with class="weight"
I thought I could get the current selected value with this:

$('.weight radio:checked').val()

...but does not seem to work. I also have them with a name="weight" so if its easier to do this by name, that would be an OK solution as well.

Thank you!
0
Comment
Question by:bbdesign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36544860
it should be

$('input[type='radio'].weight:checked').val()

or just

$('.weight:checked').val()
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36544869
to fetch by name


$('input[name='weight']:checked').val()
0
 

Author Comment

by:bbdesign
ID: 36544972
Excellent, thanks.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36544973
just add << : >> and no space before radio : $(".weight:radio:checked").val()
test page : http://jsfiddle.net/dahVc/

$(".weight:radio").change(function() {
    //alert( $(this).val() );
    alert( $(".weight:radio:checked").val() );
})

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question