Hi,
I have a select field that has an onchange attribute that fires an ajax script to fill out another field. It's working perfectly in every browser except IE, but I just cannot figure out why it's not being triggered in IE.
My code is:
The HTML:
<select name="CountryId" id="CountryId" size="1" title="Choose a country" tabindex="1" onchange="funChangeField(document.frmOrder,'Action','country');funSubmitForm(document.frmOrder);">
The js file (it's triggered first on page load to change the onchange attribute, if HTTPRequest is available, then when the field changes to fire off the HTTP Request and lastly to process the response to fill out and show the second field):
function funCountryChg(objResp, strUrl, objField, strMsgField) {
// Process a country field when it changes
var strHdgFld, strDataFld, objHdgFld, objDataFld;
if (objResp == 1) {
if (window.XMLHttpRequest || window.ActiveXObject) {
objField.setAttribute("onchange", "funCountryChg(2, '" + strUrl + "?Id=' + this.value, document.getElementById('" + strMsgField + "'));");
}
} else if (objResp == 2) {
if (objField != null && objField != '') {
objField.innerHTML = 'Please wait ...';
objField.parentNode.className = objField.parentNode.className.replace(/hide/i, 'show');
}
funHTTPReq(strUrl);
} else {
strHdgFld = objResp.getElementsByTagName('hdgname')[0].firstChild.data;
strDataFld = objResp.getElementsByTagName('dataname')[0].firstChild.data;
objHdgFld = document.getElementById(strHdgFld);
objDataFld = document.getElementById(strDataFld);
if (objResp.getElementsByTagName('showrow')[0].firstChild.data == 1) {
objHdgFld.innerHTML = objResp.getElementsByTagName('hdgcontent')[0].firstChild.data;
objDataFld.innerHTML = objResp.getElementsByTagName('datacontent')[0].firstChild.data;
objHdgFld.parentNode.className = objHdgFld.parentNode.className.replace(/hide/i, 'show');
} else {
objHdgFld.innerHTML = '';
objDataFld.innerHTML = '';
objHdgFld.parentNode.className = objHdgFld.parentNode.className.replace(/show/i, 'hide');
}
}
return true;
}
IE is definitely setting the onchange attribute, but it just refuses to fire it when the selection changes.
Can anyone tell me what I have to do differently in IE to get it to fire the onchange event?
Thanks.
Debbie