Lumio Posted December 31, 2007 Share Posted December 31, 2007 Hi! I list the categories of a web-app of mine with many Dropdown-boxes. It works great with Firefox and so on. But not with IE. So I do it like this: <?php //this is javascript function addCatBox(layer, parent) { if (parent == 0 && layer == cat_layer) return false; else if (parent == 0) { for (var i=(layer+1); i<=cat_layer; i++) { var elm_del = document.getElementById('catDropBox'+i); if (typeof elm_del != "undefined" && elm_del != "null") document.getElementById('articlepage_create_cat').removeChild(elm_del); } cat_layer = layer; return false; } if (layer < cat_layer) { for (var i=(layer+1); i<=cat_layer; i++) { var elm_del = document.getElementById('catDropBox'+i); alert(elm_del); if (typeof elm_del != "undefined" && elm_del != "null") document.getElementById('articlepage_create_cat').removeChild(elm_del); } cat_layer = layer; } cat_layer++; makeRequest ('/ajax/article_categories.php?parent='+parent, writeCategories); } function writeCategories() { if (http_request.readyState == 4) { if (http_request.status == 200) { var xmldoc = http_request.responseXML; var cats_node = xmldoc.getElementsByTagName('categories').item(0); var cats_parent = cats_node.attributes[0].nodeValue; var cats = cats_node.childNodes; var elm_cat = document.getElementById('articlepage_create_cat'); //some code... var newSelection = document.createElement('select'); newSelection.setAttribute('name', 'catDropBox'+cat_layer); newSelection.setAttribute('id', 'catDropBox'+cat_layer); //THIS HERE SHOULD CALL THE FUNCTION addCatBox WHEN THE SELECTION //CHANGES. IT WORKS ON FIREFOX AND CAMINO AND SO ON //BUT _NOT_ ON INTERNET EXPLORER 7 newSelection.setAttribute('onchange', "addCatBox("+cat_layer+", this.value);"); //...some code var bol_error = false; for (var i=0; i<cats.length; i++) { if (cats[i].nodeType == 1) { if (cats[i].nodeName == 'cat') { //... some code that defines cat_id and cat_name var newOption = document.createElement('option'); newOption.setAttribute('value', cat_id); var newOptionVal= document.createTextNode(cat_name); newOption.appendChild(newOptionVal); newSelection.appendChild(newOption); }else if (cats[i].nodeName == 'error') { bol_error = true; cat_layer--; break; } } } if (bol_error === false) { elm_cat.appendChild(newSelection); } //... some code } } I don't know, why Internet Explorer does not call addCatBox. Quote Link to comment Share on other sites More sharing options...
mike1313 Posted January 4, 2008 Share Posted January 4, 2008 Are you using your XmlHttpRequest properly? Quote Link to comment Share on other sites More sharing options...
Lumio Posted January 5, 2008 Author Share Posted January 5, 2008 Yes. I already found out, why it didn't work. I had to add an event with another property. Now this function helped me: function addEvent(el,ev,fn) { if(el.addEventListener) el.addEventListener(ev,fn,false) else el.attachEvent('on'+ev, fn) } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.