By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 1,982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Why am I having issues getting a radio value in jQuery?

Samishii23
100+
P: 246
Ok assume the following: I have most recent jQuery, and jQueryUI, the problem is occuring in code in a seperate js file within an object function.

I have 8 radio buttons, each the same name.
When I call the function which at the moment is just an alert...
Expand|Select|Wrap|Line Numbers
  1. function obj() {
  2.   this.nav = function() {
  3.     var val = $("input[name=radioButtons1]").attr("value");
  4.     alert(val);
  5.     }
  6.   }
This code produces an alert that is always the first radio buttons value despite any radio being checked, or a different radio then the one that has a different value. Same value everytime.

I use this same method in another section of my website though that is in an event method. Also this method is not within form tags. The other one is.

Whats wrong?
May 30 '11 #1
Share this Question
Share on Google+
1 Reply


Samishii23
100+
P: 246
After messing around with it. I got this code to work.
Expand|Select|Wrap|Line Numbers
  1. $("input[name=radoButtons1]:checked").attr("value").
Sorry for the wasted space.
May 30 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.