Jump to content

Duel drop down list / select list


fife

Recommended Posts

Hi all.  Im trying to create a duel dropdown list with an ajax call to populate the second list.  My first list works ok but the second list is not working at all.  Here is my code

 

 

the header info for the ajax call

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function()
{
$(".networks").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;

$.ajax
({
type: "POST",
url: "http://www.saph.info/members/iframes/foldersquery.php",
data: dataString,
cache: false,
success: function(html)
{
$(".folder").html(html);
} 
});

});

});
</script>

 

the first dropdown list


<label for="networks" ></label>
      <select name="networks" id="networks" class="networks">
       <?php 
   $sql=mysql_query("SELECT * FROM networks WHERE type = '1'");
while($row=mysql_fetch_array($sql))
{
$id=$row['idnetworks'];
$data=$row['netname'];
echo '<option value="'.$id.'" >'.$data.'</option>';
}
   ?>
      </select>

 

then I have a page called foldersquery.php with the query for the second drop down

 

include('../../Connections/db.php'); 

if($_POST['id'])
{
$id=$_POST['id'];

mysql_select_db($database_db, $db);
$query_rs_folders = "SELECT * FROM documents WHERE type = '1' AND network = '$id' ";
$rs_folders = mysql_query($query_rs_folders, $db) or die(mysql_error());


while($row=mysql_fetch_array($rs_folders))
{
$id=$row['iddocs'];
$data=$row['documentname'];
echo '<option value="'.$id.'">'.$data.'</option>';
}
}

 

 

I have no idea where my error is.

 

Thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/265413-duel-drop-down-list-select-list/
Share on other sites

  • 3 weeks later...

You can check if the AJAX request is successful by looking into the request and response in your browser: Firefox -> Firebug or Chrome Web Inspector "Net" tab.

 

This will show the request parameters and the response (including headers) of the Ajax request which will help in debugging the issue.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.