fife Posted July 12, 2012 Share Posted July 12, 2012 Ok im sorry if this is not AJAX as im not too sure if it is. Basically Im trying to make duel select lists. this is different code from my previous post as no one answered so i had to find a different solution. So here it goes I have a query that poplulates the first drop down list. //header function createoptions($table , $id , $field) { $sql = "select * FROM $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } //body in a form <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select> next I have another field <select name="folder" id="folder"> </select> Now in a different page called select.php I have this query <?php include('../Connections/db.php'); session_start(); function createoptions($table , $id , $field , $condition_field , $value) { $sql = sprintf("select * from $table WHERE $condition_field=%s AND type='1' ORDER BY $field" , $value); $res = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($res) > 0) { while ($a = mysql_fetch_assoc($res)) $out[] = "{optionValue: {$a[$id]}, optionDisplay: '$a[$field]'}"; return "[" . implode("," , $out) . "]"; } else return "[{optionValue: -1 , optionDisplay: 'No result'}]"; } if (isset($_GET['networks'])) { echo createoptions("documents" , "iddocs" , "documentname" , "parentid" , $_GET['networks']); } die(); ?> Now back on the page with the form I call this query through the following code in the header <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(function(){ $("select#networks").change(function(){ $.getJSON("select.php",{networks: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; } $("select#folder").html(options); }) }) }) </script> Now the second list is show as completely blank. Im not too sure how to trouble shoot this issue or even where to start. Can some please help Quote Link to comment https://forums.phpfreaks.com/topic/265556-file-not-being-included/ 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.