mikefrederick Posted March 2, 2008 Share Posted March 2, 2008 Thanks a lot if you can help with this. My script for chained select boxes works all the time other than in IE. in IE, it only repopulates the second box certain times. I am populating from databases. I can't figure it out.... See them at ivoiresondage.com/index.php. important script in header : function getCountries(sel) { var countryCode = sel.options[sel.selectedIndex].id; var rid = sel.options[sel.selectedIndex].value; document.getElementById('dhtmlgoodies_country').options.length = 0; // Empty city select box if(countryCode.length>0){ var index = ajax.length; ajax[index] = new sack(); ajax[index].requestFile = 'populate.php?rid='+rid+'&countryCode='+countryCode; // Specifying which file to get ajax[index].onCompletion = function(){ createCountries(index) }; // Specify function that will be executed after file has been found ajax[index].runAJAX(); // Execute AJAX function } } function createCountries(index) { var obj = document.getElementById('dhtmlgoodies_country'); eval(ajax[index].response); // Executing the response from Ajax as Javascript code } Associated files: -ivoiresondage.com/ajax.js -ivoiresondage.com/populate.php. code for populate.php: <?php include "config.php"; $action=$_GET["countryCode"]; switch($action) { case "getcountries": $rid=$_REQUEST["rid"]; $sql="select * from departments where rid='$rid' order by name"; $res=mysql_query($sql); $y.="obj.options[obj.options.length] = new Option('...','...');\n"; while($row=mysql_fetch_array($res)) { $y.="obj.options[obj.options.length] = new Option('$row[name]','$row[id]');\n"; } echo $y; break; } $actionz=$_REQUEST["category"]; switch($actionz) { case "test": $cid=$_GET["cid"]; $sqltt="select * from departments where rid='$rid' order by name"; $restt=mysql_query($sqltt); $out.="obj.options[obj.options.length] = new Option('Select a State','1');\n"; while($rowtt=mysql_fetch_array($restt)) { $out.="obj.options[obj.options.length] = new Option('$rowtt[name]','$rowtt[id]');\n"; } echo $out; break; } ?> 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.