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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:22:59+00:00 2026-06-02T04:22:59+00:00

I’m looking off of this site to make a multiple drop down: Roshan’s Blog

  • 0

I’m looking off of this site to make a multiple drop down: Roshan’s Blog

And most of it is working, I’m just having a problem with the 3rd drop down box.
(Dropdown1: Clients, Dropdown2:Location, Dropdown3:Zone)

On my page so far, if I look at the source, after selecting the first dropdown(Client1), the second dropdown statement says:
<select style="width: 150px;" id="add-event-dialog-location" name="add-event-dialog-location" onchange="getZone(Client1,this.value)">

Which is what I need, but now, when I click on one of the options in the second drop down, it is not placing through the getZone() script. The ‘zonediv’ is not changing, and I’m not sure if the rest is going through or not. If I load the getZone.php by itself and place in my own GET statements into the URL, I get results, but I can’t get them within the page I’m calling the dropdowns from.

I’m probably just missing something small, but I’ve been looking at it so long, that I just can’t figure it out.

The HTML:

<select style="width: 150px;" name="add-event-dialog-client_name" id="add-event-dialog-client_name" onchange="getLocation(this.value)">
                    <?php
                        echo "<option selected='selected' disabled='disabled'>-Client Name-</option>";
                        $result = mysql_query("SELECT DISTINCT client_name FROM spc_clients");
                        while($row = mysql_fetch_array($result)){
                           echo "<option value='".$row['client_name']."'>".$row['client_name']."</option>";
                        }
                    ?>
               </select>
               <p id="locationdiv">
               <select style="width: 150px;" name="add-event-dialog-location" id="add-event-dialog-location" disabled="disabled">
                    <option>Select Client First</option>
               </select>
               </p>
               <p id="zonediv">
               <select style="width: 150px;" name="add-event-dialog-zone" id="add-event-dialog-zone" disabled="disabled">
                    <option>Select Location First</option>
               </select>
               </p>

Both of the JS Functions:

function getLocation(client_name) {     
    var strURL="display/getLocation.php?client_name="+client_name;
    var req = getXMLHTTP();

    if (req) {
        req.onreadystatechange = function() {

            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {                        
                    document.getElementById('locationdiv').innerHTML=req.responseText;                      
                } else {
                    alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                }
            }               
        }           
        req.open("GET", strURL, true);
        req.send(null);
    }       
}

function getZone(client_name,location) {        
    var strURL="display/getZone.php?client_name="+client_name+"&location="+location;
    var req = getXMLHTTP();

    if (req) {
        req.onreadystatechange = function() {

            if (req.readyState == 4) {
                // only if "OK"
                if (req.status == 200) {                        
                    document.getElementById('zonediv').innerHTML=req.responseText;                      
                } else {
                    alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                }
            }               
        }           
        req.open("GET", strURL, true);
        req.send(null);
    }       
}

getLocation.php:

<?php 
include 'connect.php';

$client = $_GET['client_name'];

$query="SELECT location FROM spc_clients WHERE client_name='$client'";
$result=mysql_query($query) or die(mysql_error());

?>
<select style="width: 150px;" id="add-event-dialog-location" name="add-event-dialog- location" onchange="getZone(<?=$client?>,this.value)">
<option selected='selected' disabled='disabled'>-Location-</option>
<?php 
while($row = mysql_fetch_array($result)){
    echo "<option value='".$row['location']."'>".$row['location']."</option>";}
?>
</select>

getZone.php:

<?php 
include 'connect.php';

$client = $_GET['client_name']; echo $client;
$location = $_GET['location']; echo $location;

$query="SELECT zone FROM spc_clients WHERE (client_name='$client' &&     location='$location')";
$result=mysql_query($query) or die(mysql_error());
?>

<select style="width: 150px;" id="add-event-dialog-zone" name="add-event-dialog-zone">
<option selected='selected' disabled='disabled'>-Zone-</option><option><?php 
while($row = mysql_fetch_array($result)){
    echo $row['zone'];}
?>
</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-02T04:23:00+00:00Added an answer on June 2, 2026 at 4:23 am

    Try putting quotes around Client1 — without quotes, javascript thinks it’s a variable, and since you haven’t defined any variable called Client1, you’re getting an error. Putting quotes around it makes it a string, which is what you want to pass to getZone().

    Try putting this in getLocation.php:

    <select style="width: 150px;" id="add-event-dialog-location" name="add-event-dialog- location" onchange="getZone('<?=$client?>',this.value)">

    If any of your Client names have quotation marks in them, you’ll have to make sure to escape them, see here for how to do that:
    Pass a PHP string to a JavaScript variable (and escape newlines).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.