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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:04:35+00:00 2026-05-23T14:04:35+00:00

I am getting back a huge crazy JSON from an API, and I am

  • 0

I am getting back a huge crazy JSON from an API, and I am struggling with putting it inside a select box. So far I have this code:

$('#gaua').live('change', function () {

        var dropDownValue = $(this).val();

        $("#gaCell").html("<select>");

        $.each(gaAccount, function(k, v) {
            $.each(v, function(k1, v1) {
                console.log("k1 "+k1+" "+dropDownValue);
                if(k1 == dropDownValue) {
                    console.log("k1 is equal to dropDownValue");
                    $.each(v1, function(k2, v2) {
                        console.log("v1 "+v1+" k2 "+k2+" v2 "+v2);
                        $("#gaCell").append("<option value='"+v2+"'>"+k2+"</option>");
                    });
                }
            });
        });

        $("#gaCell").append("</select>");

        console.log($("#gaCell").html());

    });

When I look at the console I see this:

<select></select><option value="4434">Option 1</option><option value="43333380">Option 2</option><option value="3233223">Option 3</option> ...

Why is the <select></select> being appended initially? Should the opening tag be set, then the option values added and finally the closed select tag?

The code looks crap, but I need to get this working properly before I clean it up. Any advice would really help, 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-05-23T14:04:35+00:00Added an answer on May 23, 2026 at 2:04 pm

    You need to construct your element first, before appending it.

    When you call $('#gaCell').html('<select>'), you’re telling jQuery to append a select element, including closing tag.

    Try this:

        $('#gaua').live('change', function () {
    
            var dropDownValue = $(this).val();
    
            $select = $("<select>");
    
            $.each(gaAccount, function(k, v) {
                $.each(v, function(k1, v1) {
                    console.log("k1 "+k1+" "+dropDownValue);
                    if(k1 == dropDownValue) {
                        console.log("k1 is equal to dropDownValue");
                        $.each(v1, function(k2, v2) {
                            console.log("v1 "+v1+" k2 "+k2+" v2 "+v2);
                            $select.append("<option value='"+v2+"'>"+k2+"</option>");
                        });
                    }
                });
            });
    
            $("#gaCell").append($select);
    
            console.log($("#gaCell").html());
    
        });
    

    This way you build up the full select element including children before appending it.

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

Sidebar

Related Questions

I'm getting back a JSON string from a third party API. When I use
Let say I'm getting back a JSON nested hash (or array of hashes) from
This is a string I am getting back from FB { id: 5672*****, name:
I'm doing some string replacement on text I'm getting back from a JSON web
I am getting back a string[] from a 3rd party library. I want to
I have been sharpening the coding knives and getting back into dev. A few
Getting back in to some C work. Many of my functions look like this:
I'm just getting back into Project Euler and have lost my account and solutions,
I am getting back the IPN response from paypal. The payment_status is pending. How
I have a huge array coming back as search results and I want to

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.