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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:01:40+00:00 2026-06-04T20:01:40+00:00

I have a jQuery dialog that needs to be opened and populated with data

  • 0

I have a jQuery dialog that needs to be opened and populated with data from a database. The dialog has in it drop downs that when in a “new” mode (not editing for re-saving) cascade.

How can I load the dialog with the values from the database, while at the same time causing the cascading to happen.

I have tied using the onfocus event of the dialog when the dialog is in “edit” mode, but the focus hit every time an element gets focus. Didn’t work without being sneaky with the editing mode.

I have tried opening the dialog and using jQuery to set the dropdown, which works, but then the cascading does work.

For the cascading I am using .change on the the different dropdowns.

Not sure if the code is going to help, but will post some to itterate the jQuery functionality I am using.

The question is: How do I open a dialog, load dropdowns with information from the server and have the .change functionality work?

$('#collectDD').change(function(){
      // first change the item drop down list
      var collection = $('#collectDD').val();

      data = "coll=" + collection + "&action=getItems&func=";
      $('#addCollection').text(collection);

      $.ajax({
            url: "getItemList.php",
            type: "GET",
            cache: false,
            data: data,
            success: function (html) {
               $('#itemDD').empty();
               $("#itemDD").html(html);              
               // now update the function collection dropdown
               data = "coll=" + collection + "&action=getFunction";

            }
        });

Collection DD HTML

 <select id="collectDD" name="collectionDD">
      <option>Select Collection</option>
      <option>Option1</option>
    </select>
  • 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-04T20:01:42+00:00Added an answer on June 4, 2026 at 8:01 pm

    This doesn’t exactly match up with your tag names, and I made a little change to the data string, but I think it’s in line with what you’re looking for

    <div id="dialogbox">
        <select id="s1"></select>
        <select id="s2"></select>
        <select id="s3"></select>
    </div>
    
    <script type="text/javascript">
      $(document).ready( function() {
        $( "#dialogbox" ).dialog({
            open: function(event, ui) {
                var s1 = $("#s1").empty();
                var s2 = $("#s2").empty(); 
                var s3 = $("#s3").empty();
    
                s1[0].enabled = false;
                s2[0].enabled = false;
                s3[0].enabled = false;
    
                //load first dropdown from the database
                var data = "coll=dropdown1&val=&action=getItems&func=";
                $.ajax({
                    url: "getItemList.php",
                    type: "GET",
                    cache: false,
                    data: data,
                    success: function (html) {
                        s1.html(html);
                        s1[0].enabled = true;
                    }
                });
    
                //load the second DD when the first changes
                s1.change( function() {
                    s2[0].enabled = false; //disable until after ajax load
                    s3[0].enabled = false;
    
                    data = "coll=dropdown2&val=" + s1.text() + "&action=getItems&func=";
                    $.ajax({
                        url: "getItemList.php",
                        type: "GET",
                        cache: false,
                        data: data,
                        success: function (html) {
                            s2.empty().html(html);
                            s2[0].enabled = true;
                        }
                    });
                });
    
                s2.change( function() {
                    if (s2[0].enabled) { //test for enabled to prevent some unnessecary loads
                        s3[0].enabled = false;
    
                        data = "coll=dropdown3&val=" + s2.text() + "&action=getItems&func=";
                        $.ajax({
                            url: "getItemList.php",
                            type: "GET",
                            cache: false,
                            data: data,
                            success: function (html) {
                                s3.empty().html(html);
                                s3[0].enabled = true;
                            }
                        });
                    }
                });
            }
        });
      });
    </script>
    

    UPDATE

    Here is an example with change functions in their own functions

    <div id="dialogbox">
        <select id="s1"></select>
        <select id="s2"></select>
        <select id="s3"></select>
    </div>
    
    <script type="text/javascript">
        var s1, s2, s3, data;
    
        $(document).ready( function() {
            s1 = $("#s1").empty();
            s2 = $("#s2").empty(); 
            s3 = $("#s3").empty();
    
            $( "#dialogbox" ).dialog({
                open: function(event, ui) {
                    s1[0].enabled = false;
                    s2[0].enabled = false;
                    s3[0].enabled = false;
    
                    //load first dropdown from the database
                    data = "coll=dropdown1&val=&action=getItems&func=";
                    $.ajax({
                        url: "getItemList.php",
                        type: "GET",
                        cache: false,
                        data: data,
                        success: function (html) {
                            s1.html(html);
                            s1[0].enabled = true;
                        }
                    });
    
                    //load the second DD when the first changes
                    s1.change( changeDD1 );
    
                    //load the third DD when the second changes
                    s2.change( changeDD2 );
                }
            });
        });
    
        function changeDD1() {
            s2[0].enabled = false; //disable until after ajax load
            s3[0].enabled = false;
    
            data = "coll=dropdown2&val=" + s1.text() + "&action=getItems&func=";
            $.ajax({
                url: "getItemList.php",
                type: "GET",
                cache: false,
                data: data,
                success: function (html) {
                    s2.empty().html(html);
                    s2[0].enabled = true;
                }
            });
        }
    
        function changeDD2() {
            if (s2[0].enabled) { //test for enabled to prevent some unnessecary loads
                s3[0].enabled = false;
    
                data = "coll=dropdown3&val=" + s2.text() + "&action=getItems&func=";
                $.ajax({
                    url: "getItemList.php",
                    type: "GET",
                    cache: false,
                    data: data,
                    success: function (html) {
                        s3.empty().html(html);
                        s3[0].enabled = true;
                    }
                });
            }
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to enable a button after that i have opened a jquery dialog
I have a jquery dialog that uses a non-jquery javascript function to complete the
I have a jQuery UI Dialog that gets displayed when specific elements are clicked.
I have a jquery modal dialog that displays a partial view. The partial view
Good morning. I have a modal JQuery dialog that on Open calls and loads
I have a modal jQuery dialog and another element that takes the ESC key
I have a simple MVC website that displays a jquery dialog for editing purposes.
I have this jquery code that generates a yes/no dialog box when the user
I have a small form that contains a jQuery UI dialog to ask for
I have a modal dialog plugin written in jquery, that binds to the click

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.