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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:21:02+00:00 2026-06-07T11:21:02+00:00

I am using a jQuery modal dialog to display a drop down list for

  • 0

I am using a jQuery modal dialog to display a drop down list for users to choose from. I populate the drop downs dynamically by appending them to the empty drop down list. This works the first time, then the second time through it only displays the default options, not the dynamic ones?

function showExportDialog() {
    //create html string for drop down list
    var selectString = "<div><select id=\"selectExport\" style=\"width: 100%\"><option>-- Select Export --</option></select></div>";

    //initialize the dialog - register click handler
    var $dialog = $(selectString).dialog({
        autoOpen: false,
        title: 'Export Dialog',
        modal: true,
        //dims screen to bring dialog to the front
        width: 500,
        buttons: {
            "export": function() {
                exportAs($('#selectExport').val());
                $(this).dialog('close');
            }
        }
    });

    //dynamically generate drop down list based on model type
    switch (modelType) {
    case "SPATIAL_STATISTICAL":
        $('#selectExport').html(''); //clear the drop down list
        $("<option value='csv'>CSV (comma separated value)</option>").appendTo("#selectExport");
        $("<option value='tab'>TSV (tab separated value)</option>").appendTo("#selectExport");
        $("<option value='heat'>Heatmap (google heatmap layer format)</option>").appendTo("#selectExport");
        break;
    case "STATISTICAL":
        break;
    case "GRAPH":
        break;
    case "PATTERN":
        break;
    default:
        throw "Invalid ModelType '" + modelType + "'";
    }

    //open the dialog
    $dialog.dialog('open');
}

here is a fiddle that displays my problem:
http://jsfiddle.net/b3v3R/21/

To recreate the problem:

  1. Click ‘Show Export Drop Down’
  2. Choose an option from the drop down
  3. Click ‘Export’
  4. Click ‘Show Export Drop Down’ again

Any thoughts?

  • 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-07T11:21:04+00:00Added an answer on June 7, 2026 at 11:21 am

    If you check firebug, you’re creating a new dialog every time the button is clicked. Because your select list has an ID, you’ve now created 2 with that ID. On subsequent button clicks, a new dialog (div) is created, and a new select list WITH THE SAME ID.

    Because you’re adding options to the select list by ID, it selects the first one, not the one newly created. You should be creating your dialog once, and dynamically updating one single select list.

    Try this fiddle: http://jsfiddle.net/scalvert/Hy6ex/2/

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

Sidebar

Related Questions

I am using a jquery modal dialog to display a table of data from
I am using the jquery dialog widget to display a modal box. However when
I'm using a jQuery sortable list in which you can drop (clone) items from
I am using jQuery-UI dialog in modal modal mode to display several Edit forms
I am having difficulty using JQuery UI Modal Dialog when submitting a form. The
I'm using the jQuery UI modal dialog. I want the dialog to be fixed
I'm using a few jQuery UI modal dialogs and the positioning of each dialog
I am using the jQuery dialog widget with the modal option over a wordpress
I'm trying to display a modal form using jquery ui. I've adapted an example
I am using a function to display a dialog box that asks the users

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.