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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:11:00+00:00 2026-05-13T09:11:00+00:00

I used following code to dynamically fill DropDown controls using AJAX. Each time a

  • 0

I used following code to dynamically fill DropDown controls using AJAX. Each time a DropDown control is clicked, following statement transfers the query to an AJAX function which then forwards to a .php file to retrieve the database results.

The problem is that the same code works absolutely fine when used on the local machine even if the MySQL connection string is using the same remote server’s IP address as the host. But when I upload the files to the remote server, all DropDowns fill the same results. For example, if there are three DropDowns viz: District, Constituency, City and if I click say, City, than all the other DropDowns also shows cities in their list.

I guess the query string that I am using in the following AJAX function is not refreshing.

[HTML DropDown Code Sample]

<div id="divDistrict" name="divDistrict">
    <select class="element select medium" id="inDistrict" name="inDistrict" onclick="MakeRequest('divDistrict', 'inDistrict', 'SELECT * FROM districtmaster');"> 
    <option value="Select" selected="Select">Select</option>
    </select>
</div>

[AJAX Function]

function MakeRequest(DivName, DropDownName, SqlQuery)
{
  var xmlHttp = getXMLHttp();

  var strUrl = "../Lib/filldropdown.php?DivName=" + DivName + "&DropDownControlName=" + DropDownName + "&SqlQuery=" + SqlQuery;

  try 
  {
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4) 
        {
            HandleResponse(xmlHttp.responseText, DivName);
        }
    }
            xmlHttp.open("GET", strUrl, true);
            xmlHttp.send(null);
    }
    catch(err)
    {
        alert(err);
    }
}

[The PHP file code]

<?php
    require("dbconnection.php");
    require("dbaccess.php");

    $dropdownControlName = $_GET['DropDownControlName'];
    $query = $_GET['SqlQuery'];
    dbconnection::OpenConnection();
    $result = dbaccess::GetRows($query);
?>
<select name=" <?php $dropdownControlName ?> ">
<option>Select from the list</option>
<?php while($row=mysql_fetch_array($result))
{ ?>
    <option value="<?= $row[0] ?>"><?= $row[1] ?></option>
<?php } ?>
</select>

Please ignore the DBAccess & DBConnection references. Those files contains simple mysql_query & mysql_connect functions. Also, I am aware of the risk of passing the query in the query string. I will fix it once the DropDown fill works correctly.

  • 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-13T09:11:00+00:00Added an answer on May 13, 2026 at 9:11 am

    Ok, solved the problem. I figured out the issue. The PHP code with the line:

    <select name=" <?php $dropdownControlName ?> ">
    

    needs to be corrected with this

    <select name="<?php echo $dropdownControlName; ?>">
    

    It is working now. Thanks to all.

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

Sidebar

Ask A Question

Stats

  • Questions 380k
  • Answers 380k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Perl has a MASSIVE set of great testing tools that… May 14, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer It's kind of kludgey to do with an adjacency list… May 14, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer To answer your first question, I think the problem is… May 14, 2026 at 9:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.