I have a form that contains multiple dropdowns that are dynamically populated using AJAX not CSS, dependent upon the form above it.
The page works fine in FF and Safari, but when I try it in IE, the first dropdown is populated, but the others remain greyed out.
Here is the generated source for the section in question...
<script language="JavaScript">
function populateComp(xmlindata) {
//alert(xmlindata);
var xmldata = xmlindata.getElementsByTagName('Company');
if(xmldata.length <= 0) { // check for data
alert("no indata");
return;
}
//alert('xmldata.length = '+xmldata.length+'\n ->'+xmldata[0].childNodes.length);
for(var i = 0; i < xmldata.length; i++) {
// alert("in the loop");
var manid = '';
var manname = '';
var x, y;
x = xmlindata.getElementsByTagName('id')[i]; // get manufacturer id
y = x.childNodes[0];
manid = y.nodeValue;
x = xmlindata.getElementsByTagName('name')[i]; // get manufacturer name
y = x.childNodes[0];
manname = y.nodeValue;
var newOption = window.document.createElement('OPTION');
newOption.value = manid;
newOption.text = manname;
//alert(manid+' '+manname);
window.document.getElementById('manufacturer').options.add(newOption);
}
}
function populateType(xmlindata) {
var xmldata = xmlindata.getElementsByTagName('Printertype');
if(xmldata.length <= 0) {
alert("no indata");
return;
}
printertype.options.length = 0;
var firstOption = window.document.createElement('OPTION');
firstOption.value = '';
firstOption.text = 'Please select';
window.document.getElementById('printertype').options.add(firstOption);
for(var i = 0; i < xmldata.length; i++) {
var typeid = '';
var typename = '';
var x, y;
x = xmlindata.getElementsByTagName('id')[i]; // get type id
y = x.childNodes[0];
typeid = y.nodeValue;
x = xmlindata.getElementsByTagName('name')[i];
y = x.childNodes[0];
typename = y.nodeValue;
var newOption = window.document.createElement('OPTION');
newOption.value = typeid;
newOption.text = typename;
window.document.getElementById('printertype').options.add(newOption);
}
window.document.getElementById('printertype').disabled = false;
}
function populateCartSelect(xmlindata) {
var xmldata = xmlindata.getElementsByTagName('Cartridge');
if(xmldata.length <= 0) {
alert("no indata");
return;
}
cartridges.options.length = 0;
var firstOption = window.document.createElement('OPTION');
firstOption.value = '';
firstOption.text = 'Please select';
window.document.getElementById('cartridges').options.add(firstOption);
for(var i = 0; i < xmldata.length; i++) {
var cartid = '';
var cartinfo = '';
var x, y;
x = xmlindata.getElementsByTagName('cart_id')[i]; // get cart id
y = x.childNodes[0];
cartid = y.nodeValue;
//alert("cartid: "+cartid);
x = xmlindata.getElementsByTagName('part_info')[i];
y = x.childNodes[0];
cartinfo = y.nodeValue;
//alert("cartinfo: "+cartinfo);
var newOption = window.document.createElement('OPTION');
newOption.value = cartid;
newOption.text = cartinfo;
window.document.getElementById('cartridges').options.add(newOption);
}
window.document.getElementById('cartridges').disabled = false;
}
function priceinfo(text) {
// xml-elements: part_num and price
//alert(text);
window.document.getElementById('price_info').innerHTML = '<p><strong>$'+text+' / each</strong></p>';
window.document.getElementById('hiddenprice').value = text;
window.document.getElementById('addnum').disabled = false;
window.document.getElementById('addnum').value = '1';
window.document.getElementById('addthis').disabled = false;
}
function populateModel(xmlindata) {
var xmldata = xmlindata.getElementsByTagName('Printermodel');
if(xmldata.length <= 0) {
alert("no indata");
return;
}
printermodel.options.length = 0;
var firstOption = window.document.createElement('OPTION');
firstOption.value = '';
firstOption.text = 'Please select';
window.document.getElementById('printermodel').options.add(firstOption);
for(var i = 0; i < xmldata.length; i++) {
var typeid = '';
var typename = '';
var x, y;
x = xmlindata.getElementsByTagName('id')[i]; // get type id
y = x.childNodes[0];
typeid = y.nodeValue;
x = xmlindata.getElementsByTagName('name')[i];
y = x.childNodes[0];
typename = y.nodeValue;
var newOption = window.document.createElement('OPTION');
newOption.value = typeid;
newOption.text = typename;
window.document.getElementById('printermodel').options.add(newOption);
}
window.document.getElementById('printermodel').disabled = false;
}
function addToOrder(xmlindata) {
var xmldata = xmlindata.getElementsByTagName('Part');
if(xmldata.length <= 0) {
alert("addToOrder: no indata");
return;
}
for(var i = 0; i < xmldata.length; i++) {
var x,y;
var part_num = '';
var status = '';
x = xmlindata.getElementsByTagName('part_num')[i];
y = x.childNodes[0];
part_num = y.nodeValue;
x = xmlindata.getElementsByTagName('status')[i];
y = x.childNodes[0];
status = y.nodeValue;
var outputstr = part_num + '\n' + status;
}
window.document.getElementById('display_status').innerHTML = '<p>'+outputstr+'</p>';
doAjax('show_sess_cart.php', '', 'showSessBasedCart', 'post', '0');
}
function printerInfo() {
man = getText('manufacturer');
type = getText('printertype');
model = getText('printermodel');
return man+' '+type+' '+model;
}
function showSessBasedCart(text) {
window.document.getElementById('display_order').innerHTML = text;
}
function clearOrder() {
doAjax('mock_cart.php', 'action=delall', '', 'post', '0');
window.document.getElementById('display_order').innerHTML = '';
}
function getValue(elementname) {
returnvalue = window.document.getElementById(elementname).value;
//alert('value: '+returnvalue);
return returnvalue;
}
function getText(elementname) {
var w = window.document.getElementById(elementname).selectedIndex;
var returnvalue = window.document.getElementById(elementname).options[w].text;
//alert('text: '+returnvalue);
return returnvalue;
}
function resetValues() {
var firstOption = window.document.createElement('OPTION');
firstOption.value = '';
firstOption.text = 'Please select';
printertype.options.length = 0;
window.document.getElementById('printertype').options.add(firstOption);
window.document.getElementById('printertype').disabled = true;
printermodel.options.length = 0;
window.document.getElementById('printermodel').options.add(firstOption);
window.document.getElementById('printermodel').disabled = true;
window.document.getElementById('cartridges').options.add(firstOption);
window.document.getElementById('cartridges').disabled = true;
window.document.getElementById('price_info').innerHTML = '<br />';
window.document.getElementById('addnum').value = '1';
window.document.getElementById('addnum').disabled = true;
window.document.getElementById('addthis').disabled = true;
}
</script>
</head>
<body onload="alert('Price list: XPS');doAjax('man_list.php', '', 'populateComp', 'post', '1')">
<form action="#" method="post" name="printerform" id="printerform">
Manufacturer:<br>
<select name="manufacturer" id="manufacturer" onchange="resetValues();doAjax('type_list.php', 'man='+getValue('manufacturer'), 'populateType', 'post', '1')">
<option value="">Please select</option>
<option value="1">Epson</option><option value="2">Ricoh</option><option value="3">Lanier</option><option value="4">Copystar</option><option value="5">Dell</option><option value="6">Xerox</option><option value="7">Lexmark</option><option value="8">HP</option><option value="9">INFOPRINT</option><option value="10">Canon</option><option value="11">Brother</option><option value="12">Samsung</option><option value="13">hh</option></select><br>
Printer type:<br>
<select name="printertype" id="printertype" disabled="disabled" onchange="doAjax('model_list.php', 'man='+getValue('manufacturer')+'&typ='+getValue('printertype'), 'populateModel', 'post', '1')">
<option value="">Please select</option>
</select><br>
Model:<br>
<select name="printermodel" id="printermodel" disabled="disabled" onchange="doAjax('cartridges.php', 'man='+getValue('printermodel')+'&pl=XPS', 'populateCartSelect', 'post', '1')">
<option value="">Please select</option>
</select><br>
Available parts:<br>
<select name="cartridges" id="cartridges" disabled="disabled" onchange="doAjax('fetchprices.php', 'man='+getValue('cartridges')+'&pl=XPS', 'priceinfo', 'post', '0')">
<option value="">Please select</option>
</select><br>