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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:43:13+00:00 2026-06-17T10:43:13+00:00

I’ll start off by saying I’ve been using this example here: http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html It is

  • 0

I’ll start off by saying I’ve been using this example here:

http://roshanbh.com.np/2008/01/populate-triple-drop-down-list-change-options-value-from-database-using-ajax-and-php.html

It is formulated for cities/states etc. but I’m just trying to get it to work with my database so I’m pulling employee information out but it still has his city/state text in some places so it may look a little weird.

Also at the moment I’m just trying to get this to work with 2 drop downs, not all 3 for the moment.

Anyways, this is what I have so far, and I’m struggling to get it to work for me. Could anybody point out where I’m going wrong?

Here is what I have in index.php, it’s basically exactly the same I just have the country names swapped out for employee ID’s that are tied to a couple (fake) employee ID’s in my database.

<form method="post" name="form1">
  <table border="0" cellpadding="0" cellspacing="0" width="60%"><tbody>
<tr>
 <td width="150">Country</td>
 <td width="150"><select style="background-color: #ffffa0" name="country" onchange="getState(this.value)">
    <option>Select Country</option><option value="1">mg05</option>
    <option value="2">aa01</option></select>
 </td>
</tr>
<tr>
 <td>State</td>
 <td>
 <p id="statediv">
  <select style="background-color: #ffffa0" name="state">
   <option>Select Country First</option></select>
 </td>
 </tr> 
</tbody></table>
</form>

This is the javascript at the bottom of index.php which I kicks off the ajax request. Note, in the example he is using a mysql database, I am using ODBC to access an Access database, so keep that in mind.

<script type="text/javascript"> 
function getState(countryId)
{
   var strURL="findState.php?country="+countryId;
   var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
      if (req.readyState == 4)
      {
     // only if "OK"
     if (req.status == 200)
         {
        document.getElementById('statediv').innerHTML=req.responseText;
     } else {
       alert("There was a problem while using XMLHTTP:\n" + req.statusText);
     }
       }
     }
   req.open("GET", strURL, true);
   req.send(null);
   }
}

Below is what I have in my findState.php file, I had to adjust several things to account for the fact that he used a mysql database and I am using ODBC to get to an Access database.

<? 
$country=$_POST['country'];

    //make connection to database, bail if no connection
    $connection = odbc_pconnect('db','','');
    if (!$connection) { exit("Connection Failed: " . $connection); }

    //retrieve usernames and passwords
    $query = "SELECT (EName) FROM LoginTable WHERE EmployeeID='$country'";

    $result = odbc_exec($connection, $query);



?>
<select name="state">
 <option>Select State</option>
  <? while($row = odbc_fetch_row($result,'EName')){ ?>
  <option value=<?=$row['EName']?>><?=$row['EName']?></option> //Error on this line
  <? } ?>
</select>

All it’s giving me is that there is an error, Undefined variable: Row on line 22, which I have commented. It displays this error twice, meaning both instances where I reference $row are invalid.

Any help or insights? I’d really appreciate it!!

  • 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-17T10:43:14+00:00Added an answer on June 17, 2026 at 10:43 am

    Add quotes around option value.. check the code below.

        //make connection to database, bail if no connection
        $connection = odbc_pconnect('db','','');
        if (!$connection) { exit("Connection Failed: " . $connection); }
    
        //retrieve usernames and passwords
        $query = "SELECT (EName) FROM LoginTable WHERE EmployeeID='$country'";
    
        $result = odbc_exec($connection, $query);
    
    
    
    ?>
    <select name="state">
     <option>Select State</option>
      <? while($row = odbc_fetch_row($result,'EName')){ ?>
      <option value="<?=$row['EName']?>"><?=$row['EName']?></option> // Add quotes around option value..
      <? } ?>
    </select>
    

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
Specifically, suppose I start with the string string =hello \'i am \' me And

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.