Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:43:34+00:00 2026-05-30T14:43:34+00:00

I have seen the jquery documents, stackoverflow and other forums, but this doesn’t seem

  • 0

I have seen the jquery documents, stackoverflow and other forums, but this doesn’t seem to work.

I have a radio button in a form, and I want to get the value of the selection.

If I remove the radio button from the form, I can get it by simply

var first_val = $('input:radio[name=Question0]:checked').val();

But if I add it to to a form name=lifestyle

Any of these combinations don’t work

I have a form named lifestyle
I have tried all the options in Chrome and it doesn’t seem to work

Option 1

var first_val = $('#lifestyle input:radio[name=Question0]:checked').val();
alert($('#lifestyle input:radio[name=Question0]:checked').val());

Option 2

var first_val = $('form input:radio[name=Question0]:checked').val(); 
alert($('form input:radio[name=Question0]:checked').val());

Option 3

var first_val = $('#lifestyle input:radio[name=Question0]:checked', '#lifestyle').val();
alert($('#lifestyle input:radio[name=Question0]:checked','#lifestyle').val());

And so on..

I don’t get the value and the alert says undefined.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:43:35+00:00Added an answer on May 30, 2026 at 2:43 pm

    “If I remove the radio button from the form, I can get it by simply”

    var first_val = $('input:radio[name=Question0]:checked').val();
    

    That selector should work regardless of whether the input belongs to a form or not. You’d only need to specify the form if there are multiple forms which each have inputs with the same name.

    I would expect this to work:

    $('form[name="lifestyle"] input:radio[name=Question0]:checked').val()
    

    Option 1 doesn’t work because your form has the name “lifestyle” but you are trying to use the id selector format with a “#”. So:

    //use
    "form[name=lifestyle]"
    // not
    "#lifestyle"
    

    Option 2 looks fine to me, assuming you have only one form element on the page.

    Option 3 has the same problem with “#” selecting by id rather than name, but also by using the $("selector", context) syntax you are supposed to supply “A DOM Element, Document, or jQuery to use as context” (as explained here, not a string, but in any case providing an element as context and then looking for that element within itself doesn’t make sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen a lot of articles on this, but none dealing with jQuery,
i have seen some hand rolled solutions but does jquery out of the box
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
I have seen this (I'm also using it): $(document).ready(function(){ // do jQuery }) and
I have seen slideUp and slideDown in jQuery. What about functions/ways for sliding to
I have seen (or thought I saw) a way to use Jquery on a
You may have seen JavaScript sliders before: http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html What I'm envisioning is a circular
I'm new to building jQuery plugins. I have seen and used a lot of
I have created a jQuery animation that can be seen by clicking the Preview
I have created a drop down with jQuery that can be seen here by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.