J
jr
This AJAX function is working except it does not return the
responseText to the proper place. What happens is it writes over to
the side and there are 2 lists. One is the full select/option list
which I want to replace with the AJAX dynamic one instead of getting
two lists. I am getting the right values when I select from the
second one and do a search, just need the AJAx one to write over the
select/option in the form. I can't figure out why it isn't?
function fillZoneId() {
// alert("get_zonenms.php?bu="+bu+"&zonenm="+zonenm);
var bu = document.forms[0].search_bu.value;
//var bu= document.getElementById('search_bu').value;
var zonenm = document.forms[0].search_zonenm.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("searchzoneid").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","get_zonenms.php?zonenm="+zonenm
+"&bu="+bu,true);
xmlhttp.send();
}
This is the full list in the form that I want the AJAX list to write
over.
</div></td></tr><tr><th align='right'>Zone Id</th>
<div id='searchzoneid'><td><select name='search_zoneid'
id='search_zoneid' >
<div id='searchzonenm'>
<td><select name='search_zonenm' id='search_zonenm' >
<option value=''>Select Zone Number</option>
</td></tr><tr><th align='right'>Zone Number</th>
<div id='searchzonenm'>
<td><select name='search_zonenm' id='search_zonenm' >
<option value=''>Select Zone Number</option>
<option value='BIRTH CONTROL' >BIRTH CONTROL</option>
<option value='CIIIS' >CIIIS</option>
<option value='CIIS' >CIIS</option>
<option value='CLINIC' >CLINIC</option>
<option value='COMPOUND' >COMPOUND</option>
<option value='controlles' >controlles</option>
etc etc etc
<option value='TABS' >TABS</option>
</select>
</div></td></tr>
So this list from AJAX and PHP would come with the right selection if
it was bu= 08132 and zonenm = ciis for example.
Should write over the above list.
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='SYRINGES'>SYRINGES</option>
<option value='BIRTH CONTROL'>BIRTH CONTROL</option>
<option value='Rx'>Rx</option>
<option value='FRIDGE'>FRIDGE</option>
<option value='OVERSTOCK'>OVERSTOCK</option>
<option value='CIIIS'>CIIIS</option>
<option value='EXPIRED'>EXPIRED</option>
</select></td>
This should write over the select id=search_zonenm .
thanks,
responseText to the proper place. What happens is it writes over to
the side and there are 2 lists. One is the full select/option list
which I want to replace with the AJAX dynamic one instead of getting
two lists. I am getting the right values when I select from the
second one and do a search, just need the AJAx one to write over the
select/option in the form. I can't figure out why it isn't?
function fillZoneId() {
// alert("get_zonenms.php?bu="+bu+"&zonenm="+zonenm);
var bu = document.forms[0].search_bu.value;
//var bu= document.getElementById('search_bu').value;
var zonenm = document.forms[0].search_zonenm.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("searchzoneid").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET","get_zonenms.php?zonenm="+zonenm
+"&bu="+bu,true);
xmlhttp.send();
}
This is the full list in the form that I want the AJAX list to write
over.
</div></td></tr><tr><th align='right'>Zone Id</th>
<div id='searchzoneid'><td><select name='search_zoneid'
id='search_zoneid' >
<div id='searchzonenm'>
<td><select name='search_zonenm' id='search_zonenm' >
<option value=''>Select Zone Number</option>
</td></tr><tr><th align='right'>Zone Number</th>
<div id='searchzonenm'>
<td><select name='search_zonenm' id='search_zonenm' >
<option value=''>Select Zone Number</option>
<option value='BIRTH CONTROL' >BIRTH CONTROL</option>
<option value='CIIIS' >CIIIS</option>
<option value='CIIS' >CIIS</option>
<option value='CLINIC' >CLINIC</option>
<option value='COMPOUND' >COMPOUND</option>
<option value='controlles' >controlles</option>
etc etc etc
<option value='TABS' >TABS</option>
</select>
</div></td></tr>
So this list from AJAX and PHP would come with the right selection if
it was bu= 08132 and zonenm = ciis for example.
Should write over the above list.
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='SYRINGES'>SYRINGES</option>
<option value='BIRTH CONTROL'>BIRTH CONTROL</option>
<option value='Rx'>Rx</option>
<option value='FRIDGE'>FRIDGE</option>
<option value='OVERSTOCK'>OVERSTOCK</option>
<option value='CIIIS'>CIIIS</option>
<option value='EXPIRED'>EXPIRED</option>
</select></td>
This should write over the select id=search_zonenm .
thanks,