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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:14:09+00:00 2026-05-28T15:14:09+00:00

I have a listbox that users can add/remove from. To add, there’s a text

  • 0

I have a listbox that users can add/remove from. To add, there’s a text box and an add button which prepends the text to the top of the list if it isn’t present already. Using jQuery to hook up the events and do the list prepending.

The html for the listbox and buttons:

<select data-val="true" data-val-required="The BuyingReportRecipients field is required." id="recipients" multiple="multiple" name="BuyingReportRecipients" style="min-width:160px"></select>

<input type="text" id="new-recipients" />
<button id="add-to-recipients">Add</button>
<button id="remove-from-recipients">Remove Selected</button>

And the related javascript:

<script src="/BuyingReport/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
.
.
.

function addListValue(listName) {
    var value = $("#new-" + listName).val();
    var values = [];

    $("#" + listName + " *").each(function () { values.push(this.value) });

    if (values.indexOf(value) == -1) {
        $("#" + listName).prepend("<option selected=\"selected\">" + value + "</option>");
    }

    return false;
}

function removeSelectedListValues(listName) {
    $("#" + listName).find("option:selected").remove();

    return false;
}

$(document).ready(function () {
    $("#add-to-recipients").click(function () { return addListValue("recipients"); });

    $("#remove-from-recipients").click(function () { return removeSelectedListValues("recipients"); });
});

This all works fine in Chrome and Firefox, but IE9 doesn’t cooperate. The listbox renders as an empty rectangle (while in Chrome it obeys my min-width styling) and clicking add has no effect. Note that when I wrote this, I knew little about javascript and even less about jQuery, so everything was pieced together with what I could learn from the Google. If there is a more correct way to go about this, I’m open to it.

  • 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-28T15:14:10+00:00Added an answer on May 28, 2026 at 3:14 pm

    Try using bind instead of the click shortcut. I have had a similar issue with IE9 and the change event shortcut.

    $(document).ready(function () {
        $("#add-to-recipients").bind('click', function () { return addListValue("recipients"); });
    
        $("#remove-from-recipients")bind('click', function () { return removeSelectedListValues("recipients"); });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list box that reads from a textfile to which the user
I have a WPF ListBox that displays images loaded from a local folder, usually
I have a simple MS Access form that has 3 objects: a text box,
So I have a collection that I have in a listbox right now, which
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items
I have a ListBox that has a style defined for ListBoxItems. Inside this style,
I have a listbox that is databound to a Collection of objects. The listbox
I have a ListBox that when in focus, and when I have an item
I have a ListBox that during development I had the items in the ListBox
I have a ListBox that is bound to a list of Persons. I want

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.