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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:01:14+00:00 2026-06-18T06:01:14+00:00

I am using jQuery to add options to a select element when text is

  • 0

I am using jQuery to add options to a select element when text is added to an input box.

In FireFox & Chrome, as soon as text is added, the select is updated and clicking on the select once shows the new options as expected. In IE, the default option shows up immediately as you type, but on first click the additional options do not display. On the second click on the select, the new options show up.

How do I get IE to update immediately like Chrome and FF?

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(document).on('paste mouseup keyup change', 'input', function () {
            updateOptions();
        });

        function updateOptions() {
            setTimeout(function () {
                if ($('input').val().length > 0) {
                    newOptions = '<option>' + $('input').val() + '</option><option>A</option><option>B</option><option>C</option>';
                } else {
                    newOptions = '<option></option>'
                }
                $('select').empty().append(newOptions);
            }, 0);
        }
    });
</script>
<input type="text"/>
<select>
    <option>before</option>
</select>

The timeout is for the paste event. Sample can be seen at http://jsfiddle.net/c7G6L/4/

I tried several SO solutions:
DIV swap from JQuery – dynamic selects and options not working in IE9 but that just seemed to give the problem to FireFox.

Redrawing the select from adding options to select on focus IE9 made no difference

Using jQuery html and append instead of innerHTML Why doesn't JQuery change select options in IE?

  • 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-18T06:01:15+00:00Added an answer on June 18, 2026 at 6:01 am

    The problem is that the event handler is watching for paste, mouseup, keyup & change. Somehow that confused IE. Removing “change” from the list fixed the problem. Change was redundant in this case anyway.

    $(document).on('paste mouseup keyup', 'input', function () {
        updateOptions();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jQuery to add placeholders to each text box on a page.
Using core jQuery, how do you remove all the options of a select box,
I want to add and remove div element using jquery and adding of div
Can we Make a checkboxList using jquery like we fill the options in select
Im using JQuery to move the elements (to & fro) between 2 select many
Is it possible to open a select element using jQuery? Either that or prevent
I'm using jQuery to listen to changes to a <select multiple> element. Is there
So the situation is this: attempting to add a dropdown box using the jquery.multiselect
I am using jQuery to add some dynamic content to a website. I am
I'm using jQuery to dynamically add new divs containing a few fields. I'm adding

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.