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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:59:26+00:00 2026-06-16T22:59:26+00:00

I have a problem checking/selecting radiobuttons, checkboxes and list styles at runtime using jQuery/jQuery

  • 0

I have a problem checking/selecting radiobuttons, checkboxes and list styles at runtime using jQuery/jQuery Mobile.

Basically I have a list of checkboxes, radio buttons and select menus and what I would like to do is get the value from the database and select/tick the correct item from the checkbox/radio button group or select menu.

Here is a simple setup of what I have tried, but it did not work.

HTML:

<fieldset data-role="controlgroup">     
  <input type="radio" name="option_radio" id="option_radio_1" value="1" />
  <label for="option_radio_1">Option 1</label>  
  <input type="radio" name="option_radio" id="option_radio_2" value="2" />
  <label for="option_radio_2">Option 2</label>
</fieldset>

<fieldset data-role="controlgroup">     
  <input type="checkbox" name="option_checkbox" id="option_checkbox_1" value="1" />
  <label for="option_checkbox_1">Option 1</label>   
  <input type="checkbox" name="option_checkbox2" id="option_checkbox_2" value="2" />
  <label for="option_checkbox_2">Option 2</label>   
  <input type="checkbox" name="option_checkbox3" id="option_checkbox_3" value="3" />
  <label for="option_checkbox_3">Option 3</label>
</fieldset>

<select name="option_list" id="option_list">
  <option value="20">20</option>
  <option value="30">30</option>
  <option value="40">40</option>
  <option value="50">50</option>
  <option value="60">60</option>
  <option value="70">70</option>
</select> 

JS:

$("#option_checkbox_1").val(option_id); 
$("#option_list").val(optionlist_id);
$('input:radio[name=gender]:checked').val(gender_id);

What I tried is passing the value from the database (example 1/2/3/4 etc) from the database directly to the element.

Can anyone tell me how this should be done exactly?

  • 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-16T22:59:27+00:00Added an answer on June 16, 2026 at 10:59 pm

    To check it or give a value:

    $('#option_checkbox_1').attr('checked', 'checked');
    $('input:radio[id=option_radio_1]').attr('checked', 'checked');
    $("#option_list").val(50);
    

    and for un-checking (by removing the attribute entirely) do

    $('#option_checkbox_1').removeAttr('checked');
    $('input:radio[name=gender]:checked').removeAttr('checked');
    

    I think here is what you want

    $('#option_checkbox_'+option_id).attr('checked', 'checked');
    $('input:radio[id='+gender_id+']').attr('checked', 'checked');
    $("#option_list").val(optionlist_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Problem with checking an XMLSignature using BouncyCastle for verifying Sigantures that
I have problem with function checking collision. No matter what I do it throws
My problem involves checking if I have a valid database connection before reading from
I have problem with my query on C, I’m using the oci8 driver. This
I have a problem with checking if the username exist. It works if it
Again I have problem with checking whether DataReader object has data or not? Dim
I have a problem while checking a hashtable value. In the code below I
Hello I'm checking duplicated data from tables. I have a problem that from where
I have a problem where I retrieve and element from a list (list1), and
I have a problem with input checking. I don't want to send the request

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.