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 8072427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:01:02+00:00 2026-06-05T14:01:02+00:00

Problem: To obtain the id from a radio button using jQuery on click or

  • 0

Problem:

To obtain the id from a radio button using jQuery on click or without. The jQuery should detect if the value is already set and choose it or choose it upon click.

HTML code (Scenario 1 – no selection is made):

<th><input type="radio" name="itemquestion" id="1" value="11"></th>
<th><input type="radio" name="itemquestion" id="2" value="12"></th>
<th><input type="radio" name="itemquestion" id="3" value="13"></th>
<th><input type="radio" name="itemquestion" id="4" value="14"></th>
<th><input type="radio" name="itemquestion" id="5" value="15"></th>

HTML code (Scenario 2 – selection has been made):

<th><input type="radio" name="itemquestion" id="1" value="11"></th>
<th><input type="radio" name="itemquestion" id="2" value="12" checked="checked"></th>
<th><input type="radio" name="itemquestion" id="3" value="13"></th>
<th><input type="radio" name="itemquestion" id="4" value="14"></th>
<th><input type="radio" name="itemquestion" id="5" value="15"></th>

jQuery code:

$('input[type=radio]', $('#itembuttons')).click(
    function() {
        var pos = $(this).parent().index() + 1;
        $('#itemresponse').val(pos);
    }
);

Question:

How can the jQuery be modified so in addition to act on click() also detect which radio button has already been checked on submit and return that id (in this case it’s 2)? In other words, a user can submit the form without clicking a radio button but I want #itemresponse to contain the id value 2.

  • 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-06-05T14:01:03+00:00Added an answer on June 5, 2026 at 2:01 pm

    If you want to be populated before the user clicks on a radio button, you could add this to set the value when the page is loaded:

    $(document).ready(function () {
        var selected_id = $('form input[type=radio]:checked').attr("id");
        $('#itemresponse').val(selected_id);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background Obtain the value from a list of XML elements using a unique identifier.
Problem: I would like to download 100 files in parallel from AWS S3 using
Purpose: Obtain the public method signature(return value,parameter,method name) from java bytecode files. I am
I am trying to obtain the minimum value from a worksheet however when I
The problem: I need to obtain the selected text from a window in a
I am using Facebook's PHP SDK and Graph API to obtain all albums from
I am using EWS and wish to obtain the conversation history folder from Office365
I am having the following problem: I obtain an object from an external component
From Python Problem Set The three functions work correctly but they require executing one
Problem : I am attempting a TURNSocket (XEP-0065 - SOCKS5) using the iOS XMPPFramework

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.