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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:43:52+00:00 2026-05-23T20:43:52+00:00

I am using dialog to display a form and echo back message on submission.

  • 0

I am using dialog to display a form and echo back message on submission. That works well. I also have a dropdown menu that on selection of value from that populates 2nd dropdown. This works well on it’s own, but if I try to merge the two, then the div id=”divId” is not being displayed or populated from the change. Now i will be the first to admit that my jQuery knowledge is basic to say the least, so I would appreciate any help from the experts. I have included code for your attention and await your comments. Thanks

This code is in seperate function.js

// Function to add box

function addbox() {

    $("#boxaddform").dialog({
        autoOpen: false,
        resizable: true,
        modal: true,
        title: 'Submit a box intake request',
        width: 470,
        beforeclose: function (event, ui) {
            $("#addbox").html("");

        }

    });

    $('#boxsubmit').click(function () {

        var box = $('.box').val();
        var service = $('#service').val();
        var authorised = $('.authorised').val();
        var data = 'box=' + box + '&authorised=' + authorised + '&service=' + service;
        $.ajax({
            type: "POST",
            url: "boxesadd.php",
            data: data,
            success: function (data) {
                $("#boxform").get(0).reset();
                $('#addbox').html(data);
                //$("#form").dialog('close');
                $("#flex1").flexReload();

            }
        });
        return false;

    });

    $("#boxaddform").dialog('open');

}

html

<script language="javascript" type="text/javascript">
      $(function() {
            $("#company").change(function() {
              if ($(this).val()!="") $.get("getOptions.php?customer=" + $(this).val(), function(data) {
                $("#divId").html(data);
                });
              });
      });
</script>

<!--- Form to add box -->

<div id="boxaddform" style="display:none;">
  <form id="boxform" method="post" class="webform" name="boxform" />

        <label for="company">Select a Company:</label>
                <select name="company" id="company" />
                    <option SELECTED VALUE="">Select a Company</option>
                        <?php
                                do {  
                                ?>
                    <option value="<?php echo $row_Recordsetcust['customer']?>"><?php echo $row_Recordsetcust['customer']?></option>
                        <?php

                    } 
                                while ($row_Recordsetcust = mysql_fetch_assoc($Recordsetcust));
                                $rows = mysql_num_rows($Recordsetcust);
                if($rows > 0)

                    {
                                mysql_data_seek($Recordsetcust, 0);
                                $row_Recordsetcust = mysql_fetch_assoc($Recordsetcust);
                    }

                ?>
            </select><br />
            <div id="divId"></div><br />
        <label for="service">Enter service level:</label>
                <select name="service" id="service">
                    <option SELECTED VALUE="">Select an option</option>
                    <option value="Standard">Standard</option>
                    <option value="Rapid">Rapid</option>
                </select>
                <br />
        <label for="box">Enter a Box#:</label>
                <input id="box" name="box" type="text" class="text ui-widget-content ui-corner-all inputbox box" />

        <label for="authorised">Requested By:</label>
                <input name="authorised" type="text" class="text ui-widget-content ui-corner-all inputbox authorised" id="authorised" value="<?php echo $_SESSION['kt_name_usr']; ?>" /><br />
    <div id="addbox"></div>
      <button id="boxsubmit" class="submit">Submit</button>
  </form>
</div>

getOptions.php

<?php
    $customer = mysql_real_escape_string( $_GET["customer"] ); // not used here, it's the customer choosen

    $con = mysql_connect("localhost","root","");
    $db = "sample";
      if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }

        mysql_select_db($db, $con);
        $query_rs_select_address2 = sprintf("SELECT * FROM company_com where idcode_com = '$customer'");
        $rs_select_address2 = mysql_query($query_rs_select_address2, $con) or die(mysql_error());
        $row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2);
        $totalRows_rs_select_address2 = mysql_num_rows($rs_select_address2);



          echo 'Select delivery address'.'<select name="customeraddress">';
          echo '<option value="">Select delivery address</option>';
          while ($row_rs_select_address2 = mysql_fetch_assoc($rs_select_address2))
          {
          $address=$row_rs_select_address2['address1_com']. " ".
          $row_rs_select_address2['address2_com']. " ".
          $row_rs_select_address2['address3_com']. " ".
          $row_rs_select_address2['town_com']. " ".
          $row_rs_select_address2['postcode_com'];
          echo '<option
          value="address">'.$address.'</option>';
          }
          echo '</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-05-23T20:43:53+00:00Added an answer on May 23, 2026 at 8:43 pm

    Try putting this

    $("#company").live('change', function() {
      if ($(this).val()!="") $.get("getOptions.php?customer=" + $(this).val(), function(data)  {
        $("#divId").html(data);
      });
    });
    

    in the first part of the scripts that you provided.

    My idea is that maybe the change handling code is not capturing the dropdown and is not runned at all.
    In order to test that put alert(‘test’); inside your current $(“#company”).change(function(){…}); block.

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

Sidebar

Related Questions

I have a form in a Windows form application that I want to display
I am using jquery ui dialog box to display a form.When i click on
I am using Lightbox Gone Wild to display a modal dialog with a form
I am using jquery dialog to display my form and I use MVC 3
I am using jquery ui dialog to display form. Unfortunately, this function clears hidden
I am using ASP .NET to display a JQuery dialog that has a few
I have a form and a div within that form that I am using
Im using System.Windows.MessageBox.Show() to display a dialog to the user. One overload lets me
How to prompt browser to display open/save dialog box using jquery?
I am using PopupManager in FB4 to display a custom dialog. popwin = new

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.