I have the AJAX function below and it now works but its doing something wrong.
The xmlhttp.responseText is not writing over the list from php in the form. Instead it is creating a 2nd drop down, so there are two drop downs. The first one is the one from php in the form with all the options and the second with the right dynamic options. How can I get it to write over the select/option in the form? The 2nd one over to the left side margin is the right one from AJAX, it does pull the right dynamic list and it works but it isn't being directed properly. So I'm just not figuring out how to do that.
can you help please? thanks, Janis
This is the search form that has the full list. The list from the php page called by AJAX below should write over this section with the section below.
function fillZoneNm() {
var bu = document.forms[0].search_bu.value;
if ( window.XMLHttpRequest ) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else{ // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
document.getElementById("searchzonenm").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","get_bus.php?bu="+bu,true);
//xmlhttp.open("GET","get_bus.php?bu=" + bu,true);
xmlhttp.send();
}
echo "<tr>";
echo "<th align='right'>Zone Number</th>\n";
echo "<div id='searchzonenm'>\n";
echo "<td><select name='search_zonenm' id='search_zonenm' >\n";
getZoneNms($search_zonenm);
echo "</select>\n";
echo "</div>";
echo "</td>";
echo "</tr>";
this is the page get_ bus.php that is called by the AJAX function. This is the right list, it gets the vars from the get string in the AJAX, but it has to write over the list in the form from php? thanks again.
echo "<td><select name='search_zonenm' id='search_zonenm' onChange='fillZoneId;' >\n";
echo "<option value=''>Select Zone Number</option>\n";
while ($row = mysql_fetch_array($result)) {
$zonenm=$row['zonenm'];
echo "<option value='$zonenm'>$zonenm</option>\n";
}
echo "</select>";
echo "</td>";
Of course this second list would have the right options and would look like this after PHP processed it but it would correspond to what the user selected
<td><select name='search_zonenm' id='search_zonenm' onChange='fillZoneId;' >
<option value=''>Select Zone Number</option>
<option value='OTC'>OTC</option>
<option value='FAST MOVERS'>FAST MOVERS</option>
<option value='CIIS'>CIIS</option>
<option value='FRIDGE'>FRIDGE</option>
<option value='OVERSTOCK'>OVERSTOCK</option>
<option value='CIIIS'>CIIIS</option>
<option value='EXPIRED'>EXPIRED</option>
</select></td>