LoOpy Posted February 12, 2008 Share Posted February 12, 2008 ok now this script below is dynamicaly changing the option for the select its working perfectly in firefox 2 but not in ie 6 or 7 which sux am i missing a setting in ie or do i need to change the script?? this script abit dirty but im new to ajax so any simplification would be welcome. hope everything clear.... select 1 <select id="source" name="source" onChange="sourceSelect(this.options[this.selectedIndex].value);"> <option> Select </option> <option >Online</option> <option >Print</option> <option >Video</option> </select> select 2 <select name="sourceType" id="sourceType" /> <option> Empty </option> </select> function function getHTTPObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } var xmlHttp=null; } function sourceSelect(selectedValue){ var typeArray = ''; var x = Array(); //gen array var v = ''; //var document.getElementById('sourceType').options.length = 0; var req = getHTTPObject(); req.open('GET', 'includes/ajax.php?name='+selectedValue, true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { typeArray = req.responseText; x = typeArray.split(','); for (v in x){ document.getElementById('sourceType').options[v] = new Option(x[v],x[v]); } } }; req.send(null); }var req = null; ajax.php queries database which returns string to function echo 'Select,opj1,obj2,obj3'; Quote Link to comment Share on other sites More sharing options...
LoOpy Posted February 12, 2008 Author Share Posted February 12, 2008 sorry thanks been fixed stupid little error ie like values in the options. 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.