stijn0713 Posted November 2, 2012 Share Posted November 2, 2012 Based on the faculty they select, different programs should appear in another select dropdown list. I tried 2 methods, neither of them work in IE... they do work in all other browsers. First method tried: on the server side: if(isset($_GET['fac'])){ $fac = $_GET['fac']; $display = "<option value=''>Studierichting:</option>"; foreach ($richtingen as $num => $array){ foreach ($array as $faculteit => $richting){ if($faculteit == $fac){ $display .= '<option value ="'.$richting.'">'.$richting.'</option>'; } } } echo $display; } in javascript: function dropdownlist(listindex) { 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() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //alert(xmlhttp.responseText); document.getElementById("studierichting").innerHTML=xmlhttp.responseText; //--> doesn't work like this in IE } } var queryString = "?fac=" + listindex; xmlhttp.open("GET","welke_fac.php" + queryString,true); xmlhttp.send(); } Second try: server side: if(isset($_GET['fac'])){ $fac = $_GET['fac']; $display = ''; foreach ($richtingen as $num => $array){ foreach ($array as $faculteit => $richting){ if($faculteit == $fac){ $display .= $richting.','; } } } echo $display; } js: var zipstring = xmlhttp.responseText; var ziparray = zipstring.split(","); //alert(ziparray.length); for(var i=0; i < ziparray.length-1; i++) { studierichting.options[i] = new Option(ziparray[i],ziparray[i]); } according to this site it should prevent the bug in IE: http://support.micro...kb;en-us;276228 . however, also this method works for every browser except IE... Thoughts? Thanks in advance 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.