i am creating multiple drop list that one is based on the previous selection of the other drop down list mean that i need to when the user choose a country only the villages in this country will appear but this was not done anyone can help me ?? this is the chunk of code for jquery and ajax with HTML
search.php
<script language="javascript" type="text/javascript">
$(document).ready(function() {
// alert('ededeededededed');
$('#countryid').change()(function(){
alert('ededededed');
var country_name = $('#countryid').val();
//var email = $('#email').val();
//var comments = $('#comments').val();
$.ajax({
url: 'search.php',
type: 'POST',
data: 'country=' + country_name,
success: function(result){
$('#districtid').html(result);
}
});
return false;
});
});
</script>
<body>
<?php require_once('header.php'); ?>
<h1>Search for Friends</h1>
<div id="searchpage">
<table width="80%" height="172">
<tr>
<td width="14%" height="166" valign="top"><?php require_once('leftsideBar.php'); ?>
</td>
<td width="86%" valign="top"><h2 class="searchtitle">Search Types</h2>
<table width="95%" height="94">
<form action="search.php" method="post" id="searchForm">
<tr>
<td><p style="color:#FF0000" align="center"><!--<?php print("$message")?>--></td>
</tr>
<tr>
<td width="20%"><label for="searchByName">By Name</label>
<select name="name" >
<option value="0">-- Select Name --</option>
<?php nameQuery(); ?>
<option id="0">-- select By UserName --</option>
</select></td>
<td width="20%"><label for="searchByCountry">By Country</label>
<select name="country" id="countryid" >
<option value="0">-- Select the Country --</option>
<?php countryQuery(); ?>
</select></td>
<td width="25%"><label for="searchByDistrict">By District</label><br />
<select name="district" id="districtid" >
<option value="0">-- Select the district--</option>
<option id="0" disabled="disabled">-- select District --</option>
<?php districtQuery(); ?>
</select></td>
<td width="15%"><label for="searchByCity">By Village</label><br />
<select name="village" >
<option value="0">-- Select the village --</option>
<option id="0" disabled="disabled">-- select Village --</option>
<?php villageQuery(); ?>
</select></td>
<td width="20%"><label for="searchBySpecialization">By Specialization</label>
<select name="specialization">
<option value="0">-- Select the Job --</option>
<option id="0" disabled="disabled">-- select Job --</option>
<?php specializationQuery(); ?>
</select></td>
</tr>
<tr>
<td><input type="submit" name="search" value="Search..." onclick='ajaxFunction()' /></td>
</tr>
</form>
</table>
</tr>
</table>
.post()
, I am saying that your PHP does not handle any incoming POST values. Currently your$.ajax()
is trying to POST date to search.php, while that file (if you are showing the complete file), has absolutely no logic to handle incoming POST data. I am not sure what you are expecting the ajax call to actually do if you can't handle the data that is being POSTed. – Mike Brant Mar 15 at 0:35