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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:44:00+00:00 2026-05-30T04:44:00+00:00

I have the following MySQL table: | id | Title | Windows | Linux

  • 0

I have the following MySQL table:

|  id   |    Title    |  Windows | Linux | IDE | GUI | RAD |
------------------------------------------------------------
|   1   |  Software_1 |     1    |   0   |  1  |  0  |  0  |
------------------------------------------------------------
|   2   |  Software_2 |     0    |   1   |  0  |  1  |  0  |

I would like to populate a form by querying the mySQL db. Up to now I’m able to populate input fields, textareas and checkboxes but I’m absolutely stuck on populating radiobuttons. Please note that mySQL stores boolean values for: checkboxes (Windows, Linux)
and radiobuttons (IDE, GUI, RAD)

This is the PHP part that retrieves the data from the dB and converts it to JSON:

while($review = mysql_fetch_array($qry)) {
    $arr = array('id_field' => $review['id'],
                'title' => $review['title'],
                'homepage' => $review['link_homepage'],
                'windows' => $review['Windows'] == "1",
                'linux' => $review['Linux'] == "1",
                'ide' => $review['IDE'] == "1",
                'gui' => $review['GUI'] == "1",
                'rad' => $review['RAD'] == "1"
    );
    echo json_encode($arr);
} 

This is the form:

<form name="form" id="edit_review" method ="post" action="review.php">  
    Language name: <input type="text" size="34" value="" name="title"/>
    Windows <input type="checkbox" name="windows" />
    Linux <input type="checkbox" name="linux" />

    IDE <input type="radio" name="environment" id="ide" value="ide"/>
    GUI <input type="radio" name="environment" id="gui" value="gui"/>
    RAD <input type="radio" name="environment" id="rad" value="rad"/>
</form>

This is the jQuery code:

$(".editlink").click(function() {
    $.get("lists.php", {param2: $(this).attr('id')}, 
        function(data) {
            jsonOBJ = jQuery.parseJSON(data);
            for (var key in jsonOBJ) {
                $(":input[name='" + key + "']").val(jsonOBJ[key]);
                $(":input[name='" + key + "']").attr("checked", jsonOBJ[key]);
            }
        }   
    );    
    return false;
 });

The string:

$(":input[name='" + key + "']").attr("checked", jsonOBJ[key]);

works only for checkboxes. Radiobuttons ‘name’ is ‘environment’ and must be the same for all the three radiobuttons. So, of course the above line is not working. I tried changing it to:

$(":input[id='" + key + "']").attr("checked", jsonOBJ[key]);

and I added ‘id‘ to the radiobuttons as follows:

IDE <input type="radio" name="environment" id="ide" value="ide"/>

and I noticed (using ‘alert’) that the correct checkbox is checked but as soon as the LOOP continues is immediately unchecked. Why radiobuttons are unchecked and checkboxes are not? How can I fix it?

  • 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-30T04:44:01+00:00Added an answer on May 30, 2026 at 4:44 am

    It depends on the version of jquery you are using. Please look at: How to reset radiobuttons in jQuery so that none is checked for your answer.

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

Sidebar

Related Questions

I have the following MySQL table: | id | Name | Windows | Linux
I have a table in MySQL That looks like the following: date |storenum |views
I have a MySQL table laid out like this: ID | Artist | Title
I have mysql table with following fields id (which auto increments) title,name,age,institution,iod the fields
I have a MySQL table (table1) with following fields... id, title, description, detail, category,
Basically I have a mysql query something like the following: mysql_query(SELECT n.title, v.value FROM
I have 2 mysql tables 1. questions: with the following columns: id, title, answer1,
I have the following MySQL table structure: num field company phone website 1 Gas
I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id |
Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)

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.