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

  • Home
  • SEARCH
  • 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 6066403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:29:50+00:00 2026-05-23T09:29:50+00:00

In my code i am using a group of radio button having same id

  • 0

In my code i am using a group of radio button having same id and name for all of the radio buttons.. but its value is different…

I have that value of the radio button that i want to be selected.. how can select that radio button using the value i have.
consider an example..

 <input name="newColorCode" id="newColorCode" type="radio" value="color_code_LightViolet"/>
<input name="newColorCode" id="newColorCode" type="radio" value="color_code_red"/>
<input name="newColorCode" id="newColorCode" type="radio" value="color_code_green"/>

i have the value color_code_green.. how can i make the corresponding radio button selected using jquery????

i tried this

       $('input:radio[value=color_code_green]').checked=true;

but its not working

  • 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-23T09:29:51+00:00Added an answer on May 23, 2026 at 9:29 am

    First, ids must be unique in the whole DOM. So having 3 radios with id="newColorCode" is wrong. So start by removing those id attributes or provide unique ones for each button. Then to answer your question:

    $(':radio[value="color_code_green"]').attr('checked', 'checked');
    

    And here’s a live demo.

    The reason your code doesn’t work is because the $(..) function returns an array of jQuery wrapped DOM elements for which the checked property which you are trying to set is simply not defined. So you could use the .attr() function in order to do this to all elements returned by your selector.

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

Sidebar

Related Questions

i am having three group of radio buttons and using the below code for
I have this group of radio buttons in which each of individual button has
I have two radio button <input tabindex=3 type=radio name=gender id=gender value=M>Male&nbsp;<input tabindex=4 type=radio name=gender
I have added a group of radio buttons dynamically to the DOM using jQuery.
I have group of radio buttons, each group ranges from 5 - 27 radiobuttons.
I am having trouble using JQuery to work with multiple radio button groups. The
I have a radio group with two radiobuttons. each button has a custom selector.
I have the following HTML: <div class=row1> <input type=radio name=group1 value=0 checked=checked/>Zero <input type=radio
<input type="radio" name="group" value="book_folder" onchange="makeRadioButtons()">Create New Book</input> <input type="radio" name="group" value="book_chapter" onchange="makeCheckBoxes()">Create New Chapter</input>
I constructed the radio button group using f:selectItems . I constructed the radio button

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.