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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:41:56+00:00 2026-06-03T23:41:56+00:00

I have a dynamic select that needs to be driven off another select, but

  • 0

I have a dynamic select that needs to be driven off another select, but I cannot seem to get it working in IE (using IE9). I’ve seen this post here but (unless I’m not understanding it) this didn’t seem to help: Dynamic Related Selects with jQuery, not work in IE.

I’ve really simplified it so that it’s easy to understand the problem. I have 2 selects, and 1 drives the other. So, when you select something in the first one, the second one changes. For this example I’m just adding a new item to the select and even this doesn’t work in IE:

var mydiv = $("#testdiv");
$("<select id='f1'>").appendTo(mydiv);
$("<select id='f2'>").appendTo(mydiv);
$("#f1").append("<option value='1'>1</option>");
$("#f1").append("<option value='2'>2</option>");
$("#f2").append($("<option>").attr("value", "n"));
$("#f1").change(function () {
    $("#f2").append("<option value='t1'>t1</option>");
});

<div id="testdiv"></div>

So, in theory we should start with 2 select lists and “f2” will 1 blank option in it.

Next, select an item from “f1” and it will add a new option to “f2”.

This works exactly as I want in firefox and chrome. In IE it just behaves oddly. Take this example in IE:

Scenario 1

  1. I open the page and check the “f2” select. It has 1 blank value
  2. I select an item in “f1”
  3. I check “f2” and it still has 1 blank value

Scenario 2

  1. I open the page and don’t touch the “f2” select.
  2. I select an item in “f1”
  3. I check “f2” and it has 2 items!
  4. I select another item in “f1”
  5. I check “f2” and it still has 2 items?!?

So it looks like the first time I activate the select control it must do something with the existing HTML… and now that’s all it’s going to render from here on…

This is driving me nuts, what am I doing wrong?!?

Note: Not sure if it matters, but both of the selects are dynamically generated using javascript/jquery because I don’t know their values until an async call completes.

Updated question due to investigation through comments… Seems my last note on the dynamic creation of the objects was crucial to recreating the problem

  • 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-03T23:41:57+00:00Added an answer on June 3, 2026 at 11:41 pm

    Figured it out. Read on a few websites about some bugs with selects in IE and having to use divs as a workaround. So the solution is to repost the html in the div each time you want to refresh the list. Something like this:

    var mydiv = $("#testdiv");
    var mydiv2 = $("#testdiv2");
    $("<select id='f1'>").appendTo(mydiv);
    $("<select id='f2'>").appendTo(mydiv2);
    $("#f1").append("<option value='1'>1</option>");
    $("#f1").append("<option value='2'>2</option>");
    $("#f2").append($("<option>").attr("value", "n"));
    $("#f1").change(function () {
        var tempdiv = $("<div>");
        $("#f2").append("<option value='t1'>t1</option>");
        $("#f2").appendTo(tempdiv);
        $("#testdiv2").html($(tempdiv).html());
    });
    
    ...
    
    <div id="testdiv"></div>
    <div id="testdiv2"></div>
    

    The important part being “testdiv2” and populating it with the html from “tempdiv”. Might be a neater way to do this but in the mean time the above works for me. Here’s a working solution in jsfiddler: http://jsfiddle.net/VHPt5/4/

    Update

    Also, a slightly different way to achieve the same thing as posted in a comment by @Ingenator in a different answer below. Rather than replacing the HTML like this:

    $("#f2").appendTo(tempdiv);
    $("#testdiv2").html($(tempdiv).html());
    

    You can clear the original div and re-append it:

    $("#testdiv2").clear();
    $("#f2").appendTo($("#testdiv2"));
    

    Ultimately, the same solution, but removing the need to generate a tempdiv in order to replace the html of the first div.

    Solution here: http://jsfiddle.net/cAr57/3/

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

Sidebar

Related Questions

I am working on a project that needs a database. I have found a
I have a select which needs to have dynamic WHERE CASE conditions. SELECT *
I'm using SQL Server 2k8 and have a table that needs to be able
I am trying to follow this tutorial (http://railscasts.com/episodes/88-dynamic-select-menus) to get dynamic select boxes working
I have... a dynamic populated select box several input boxes a submit button form
I have some divs that have dynamic heights controlled by a 'click' function as
I have some divs that have dynamic heights controlled by a 'click' function as
I have a dynamic text file that picks content from a database according to
I have a dynamic list of items that will be used to POST information
I have an ASP.NET application which needs to search a VARCHAR(20) column using lists

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.