Home|Sitemap|Contact

How can you update a companion drop down list when the first list changes, by querying the database but not refreshing the whole page?

In compiled VB or VB.NET you can use the XMLHTTP object.  You also can use that object in an ASP page (or even JavaScript in most browsers.)
First Field:  Second (remote query) Field: X


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

<head>
<title>rodsdot.com :: simulation of client communication with web service</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005, 2006 Roderick Divilbiss">
<script type="text/javascript">
var sending=false;

//create the Cross-browser XMLHttpRequest object
function getFile(pURL,pSend) {
  alert('Sending a request to rodsdot.com for userid: '+pSend);
  //if (!sending) {
  if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
    xmlhttp=new XMLHttpRequest();
    if (xmlhttp.overrideMimeType) {
      xmlhttp.overrideMimeType('text/xml');
    } 
    xmlhttp.onreadystatechange=postFileReady;
    xmlhttp.open("GET", pURL+'?userid='+pSend, true);
    xmlhttp.send(null);
  } else if (window.ActiveXObject) { //IE 
    xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
    if (xmlhttp) {
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open('GET', pURL+'?userid='+pSend, false);
      xmlhttp.send();
    }
  }
}

// function to handle asynchronus call
function postFileReady() {
  if (xmlhttp.readyState==4) { 
    if (xmlhttp.status==200) { 
      document.getElementById('theExample').innerHTML=xmlhttp.responseText;
    }
  }
}

</script>
</head>

<body>
<div id="theExample">The web site messages will appear here...</div>

<p><select size="1" name="userid" id="userid">
     <option>Select name to send</option>
     <option value="rdivilbiss">rdivilbiss</option>
     <option value="alangsk">alangsk</option>
     <option value="joesmoe">joesmoe</option>
     <option value="unknown">unknown</option>
   </select>&nbsp;
<input type="button" value="Send Request" onclick="getFile('http://www.rodsdot.com/ee/serverTime.asp',document.getElementById('userid')[document.getElementById('userid').selectedIndex].value)"</p>
</body>
</html>


Most Popular Pages On rodsdot.com

Client Side Includes Using JavaScript
Creating A JavaScript Slider Input in JavaScript
Creating Conditional Links With ASP
Dynamically Adding Rows and Fields To A Table Based Form
Geo-Coding IP Addresses
How To Make A Pop Over Menu
JavaScript Date Validation DD/MM/YYYY
JavaScript Date Validation MM/DD/YYYY
Parameterized SQL Using Multiple Form Inputs and Filtering
Play A WAV File On Mouseover
Pop Over Form
Resorting A Multi-Dimensional Table Using Client-Side JavaScript
Scripting Remote Images in JavaScript
Using AJAX to Return HTML For Dynamic Forms
Using Images For CAPTCHA
Using Parameterized SQL with ASP and MS Access
Why JavaScript As The HREF Of A Link Is Bad