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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:09:03+00:00 2026-06-03T09:09:03+00:00

This is the JSON that is returned from my PHP { 17:{answer_id:17,answer:You earn a

  • 0

This is the JSON that is returned from my PHP

{
"17":{"answer_id":"17","answer":"You earn a salary","is_correct":"N"},
"18":{"answer_id":"18","answer":"You earn profit","is_correct":"N"},
"19":{"answer_id":"19","answer":"You invest money","is_correct":"N"},
"20":{"answer_id":"20","answer":"All of the above.","is_correct":"Y"}
}

So I basically need to loop through this and display them as radio button options.
But I’m stuck – I checked out this solution
jQuery $.each loop and json data

But that is just one array and also the other issue I have is with the key being a number.

Any help will be appreciated

Thanks

  • 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-03T09:09:04+00:00Added an answer on June 3, 2026 at 9:09 am
    var ret = {
    "17":{"answer_id":"17","answer":"You earn a salary","is_correct":"N"},
    "18":{"answer_id":"18","answer":"You earn profit","is_correct":"N"},
    "19":{"answer_id":"19","answer":"You invest money","is_correct":"N"},
    "20":{"answer_id":"20","answer":"All of the above.","is_correct":"Y"}
    };
    
    $.each(ret, function(key, value) {
    
       var radio_with_label = $('<label for="'+ value.answer_id +'">'+ value.answer +'</label><input name="'+ key +'" id="'+ value.answer_id +'" type="radio" value="'+ value.is_correct+'">');
    
       $(TARGET).append(radio_with_label); // TARGET -> any valid selector container to radios
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in PHP I create this object that I convert to JSON and send to
Well ive got this code that creates a table from JSON data. If a
I have a JSON string(?) that I have returned from $.ajax() and named it
I have a PHP script that attempts to read and parse JSON strings returned
I have this swf (flash) file that provides the json that needs to be
I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have to process JSON files that looks like this: \u0432\u043b\u0430\u0434\u043e\u043c <b>\u043f\u0443\u0442\u0438\u043c<\/b> \u043d\u0430\u0447 Unfortunately,
I have a JSON string that looks like this: { package1: { type: envelope,
I have a Nancy JSON REST service that uses the following serialisation code... FormatterExtensions.AsJson(this.Response,
I have this JavaScript string that contains and array of malformed JSON and I

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.