How to populate a drop down menu from a database without refreshing the page

I have form on my page and based on what the user chooses from the first drop down menu, I want the next drop down menu to populate with values from a database.  I've attached a copy of the code and the asp function I'm trying to call.

When I select my survey project from the 1st drop down, I get the alert -> There was a problem while using XMLHTTP: Internal Server Error.

The getsurvey.asp code appears to be working and I've included the output from this function when I test the program in my browser.

Can someone please help me figure out what I'm doing wrong?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My title</title>
<SCRIPT TYPE="text/javascript">
<!--
window.focus();
 
function getSurveys(dbPath)
{
   var strURL="getsurvey.asp?dbpath=" + dbPath;
   var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   if (xmlhttp)
   {
      xmlhttp.onreadystatechange = function()
      {
         if (xmlhttp.readyState == 4)
      	{
	   // only if "OK"
	   if (xmlhttp.status == 200)
         	   {
	      document.getElementById('surveydiv').innerHTML=xmlhttp.responseText;
	   } else {
   	      alert("There was a problem while using XMLHTTP:\n" + xmlhttp.statusText);
	   }
       	}
      }
      xmlhttp.open("GET", strURL, true);
      xmlhttp.send(null);
   } else {
      alert("There was a problem creating the xmlhttp object");
   }
}
 
//-->
</SCRIPT>
</head>
 
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td align="left" valign="top">Project Survey:</td>
    <td align="left" valign="top">
      <select name="Projects" onChange="getSurveys(this.value)">
        <option>Select Project Survey</option>
        <option value="mypath\mydbname.mdb">Survey Project 1</option>
      </select>
    </td>
  </tr>
  <tr>
    <td align="left" valign="top">Program Survey:</td>
    <td align="left" valign="top">
      <p id="surveydiv">
        <select name="survey"><option>Select Project Survey First</option></select>
      </p>
    </td>
  </tr>
</table>
</body>
</html>
 
 
******************************************************************
getsurveys.asp
******************************************************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252" ENABLESESSIONSTATE = True %>
<% Option Explicit %>
<!--#include file="functions.asp"-->
<%
Dim MyConn, ConnStr, rs, dbPath, dbName
 
dbName = "\" & Right(Request.QueryString("dbpath"), Len(Request.QueryString("dbpath")) - InStrRev(Request.QueryString("dbpath"), "\"))
dbPath = Left(Request.QueryString("dbpath"), Len(Request.QueryString("dbpath")) - Len(dbName))
Call OpenDatabase(MyConn, adModeShareDenyNone, dbPath, dbName)
 
ConnStr = "SELECT presenterid, program FROM Presenter;"
set rs = MyConn.Execute(ConnStr)
%>
<select name="surveys">
	<option>Select Program Survey</option>
	<% do while rs.EOF = false %>
	<option value=<%=rs("presenterid")%>><%=rs("program")%></option>
	<%		rs.MoveNext
		loop %>
</select>
<% Call Database_Close(MyConn) %>
 
*********************************************************************
getsurveys.asp output
********************************************************************
 
<select name="surveys">
	<option>Select Program Survey</option>
	
	<option value=37>Program 1</option> -->
	
	<option value=33>Program 2</option>
	
	<option value=34>Program 3</option>
	
	<option value=35>Program 4</option>	
	<option value=36>Program 5</option>	
</select>

Open in new window

dyaroshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ASPSQLServerCOMCommented:
first try this example
The reference site W3Schools has a good section on AJAX http://www.w3schools.com/ajax/default.asp.

There is also a good explanation on what AJAX is at http://en.wikipedia.org/wiki/Ajax_%28programming%29
http://www.skeymedia.com/programming/classic-asp-and-ajax-tutorial/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Albert Van HalenAnalyst developerCommented:
Perhaps a typo ?? Your page is called getsurveys.asp, yet you make a request to getsurvey.asp.
0
dyaroshAuthor Commented:
Thanks for the help.  Your solution worked.  Also, the typo was in my posting where I labeled the program name.
0
Albert Van HalenAnalyst developerCommented:
Hi dyarosh, like to hear what your solution was for your problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.