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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:47:16+00:00 2026-06-12T17:47:16+00:00

Hi all i am appending data to a dropdown dynamically in my application but

  • 0

Hi all i am appending data to a dropdown dynamically in my application but i have an error here ,the drop downs are created but the values are binded outside the dropdown can any one correct me here where am i doing wrong

      if(product.oPTIONS.length>0)
            {
            alert(product.oPTIONS.length);
            $.each(product.oPTIONS, function (idx, options) {                    
                $("#productdetails").append('<label>' + options.OptionName + '</label>');
                if(options.value.length>0)
                {
                    var stringBuilder = [];                      
                    $("#productdetails").append('<select>');
                    $.each(options.value, function (idx, values) {
                        stringBuilder.push('<option id="' + values.OptionvalueID + '">' + values.OptionValue + '</option>');                    
                    });
                     stringBuilder.push('</select>');
                    $("#productdetails").append(stringBuilder.join(''));
                }
            });
  • 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-12T17:47:18+00:00Added an answer on June 12, 2026 at 5:47 pm

    From what you’ve stated I’m guessing that you’ve got a model with a dropdown already created using Html.DropDownListFor for the element productdetails and that you want to populate it from the an ajax call.

    So you want to make a jQuery ajax call like this

    $.ajax({
                    url: "/SomeController/SomeDetails",
                    type: "GET",
                    success: function (data) {
                        $("#productdetails option").remove();
                        $.each(data, function (key, value) {
                            $('#productdetails')
                                        .append($("<option></option>")
                                        .attr("value", key)
                                        .text(value));
                        });
                    }
                });
    

    If you don’t want to remove the old values of the select, then just remove the line $(“#productdetails option”).remove();

    Also note that my controller method returns a JSON Object of key value pairs for the option elements.

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

Sidebar

Related Questions

I'm building application on Google AppEngine with Java (GAE/J) and all my data will
I have a dropDownList1 with 3 values: N, U, All. I have dropDownList2 that
I am trying to load data into an extjs 4 TreeStore but while appending
I have created simple .aspx page which queries a database for some live data
Hi all i am having some which i am appending to a div dynamically
All, If I've go the following database fields/values: user_id field_name field_value 1 EventHour1 1
All -- I have these two methods in one of my classes: public static
All, How can I bind the array of drop down list items returned from
all. We're trying to get some intersect collisions working, but the problem experience is
Is it possible to access $_POST variables without appending all the form elements into

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.