I have a page that has two drop down lists. The first list is somewhat static. I have placed onChange event in this dropdown to trigger an Ajax call to load values into the 2nd dropdown that is dynamically produced via asp script. This must be done via server side script because the values are different for different people and these values can change
This works great in IE. Other browsers only allow for 1st change to refill the
2nd dropdown. Any subsequent changes to the first dropdown produce no results.
Here is the 1st drop down list as I have it right now
Code:
<select name="JobFam" size="1" onChange="JobList(this.value,'AT45AT','N','SBSECA');">
<option value="Admin">Administrative</option>
<option value="Artistic">Artistic/Advertising</option>
<option value="College">College</option>
<option value="Cosmetology">Cosmetology</option>
<option value="Custom" Selected>Custom</option>
<option value="DirecttoWork">Direct to Work</option>
<option value="ZZZ">Equipment Dealer Jobs</option>
<option value="Generic">Generic</option>
<option value="HRS">HR Jobs</option>
<option value="Indust">Industrial</option>
<option value="Mngt">Management</option>
<option value="Mech">Mechanical</option>
<option value="Medical">Medical</option>
<option value="Prof">Professional</option>
<option value="Restaurant">Restaurant</option>
<option value="Sales">Sales</option>
<option value="Scien">Scientific</option>
<option value="Service">Services</option>
<option value="Social">Social Services</option>
<option value="Techno">Technological</option>
<option value="Trades">Trades & Vocational</option>
</select>
Here is the javascript function
Code:
function JobList(str, sMaster, sCFM, sSec){
var xmlHttp;
if (navigator.userAgent.indexOf("MSIE")>=0){
var strName="Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
strName="Microsoft.XMLHTTP";
}
try{
xmlHttp = new ActiveXObject(strName);
}
catch(e){
//alert("Error. Scripting for ActiveX might be disabled")
return e
}
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
var url="GetJobs.asp";
var params = "db="+str+"&master="+sMaster+"&sec="+sSec+"&cfm="+sCFM;
//alert(params)
xmlHttp.open("POST", url , true)
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("jobs").innerHTML=xmlHttp.responseText
}
}
xmlHttp.send(params)
}
The Error console in Firefox will tell me the following
Error: JobList is not a function
AS we can clearly see it is indeed a function
in Chrome if I run firebug I can only see this the very first time
POST GetJobs.asp
200 OK
154ms
If I clear the console then I see nothing (it is like the onchange event is not being triggered)
Any ideas what I need to do?
BTW this is done in Ajax because a database holds the values for the 2nd drop down and these are different for different users and there are thousands of users (hundreds of thousands of different values)