sorry, here's the function that's called by the event and calls the callback function.
Code:
function eventHorizon(place, which){
var dropdown = document.getElementById(which+'_country');
var choice = dropdown.selectedIndex;
var choice_text = dropdown.options[choice].text;
var num;
switch(choice_text){
default:
num = 0;
break
case 'United States of America':
num = 1;
break
case 'Canada':
num = 3;
break
case 'United Kingdom':
num = 2;
break
}
if(num != 0){
document.getElementById(place).innerHTML="Starting...";
xmlHttp=createXMLHttpRequest();
var url="u_info_supp.php?id="+num;
xmlHttp.onreadystatechange=callback(place)
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}else{
document.getElementById(place).innerHTML='';
}
}
here's the html.
Code:
<p id="place2"></p>
<p>Country: <select name="c_country" id="c_country" onchange="eventHorizon('place2', 'c')">
<?php
for($x=0; $x < count($countries[0]); $x++){
if(($countries[0][$x] == 'United States of America') || ($c_country == $countries[0][$x])){
echo "<option value=\"".$countries[0][$x]."\" selected=\"selected\">".$countries[0][$x]."</option>";
}else{
echo "<option value=\"".$countries[0][$x]."\">".$countries[0][$x]."</option>";
}
}
?></select></p>
id "place2" is where the response text goes.