upewnij się, że nigdy nie zostawiasz znacznika zamykającego php i błagania nagłówka html, może to spowodować kilka nieprzyjemnych błędów
ten skrypt powinien działać
<?php
require_once('func.inc.php');
connect();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testDroplistdown</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p align="center">
<div id="dropdown1div"><select id="dropdown1" name="dropdown">
<?php countryQuery(); ?>
</select></div>
</p>
<br />
<br />
<p align="center">
<div id="dropdown2div"></div>
</p>
<p align="left">
<div id="dropdown3div"></div>
<script type="text/javascript">
$("#dropdown").change(function() {
val = $(this).val();
var html = $.ajax({
url: "dropdown_select.php?dropdown=2&val="+val+"",
async: true,
success: function(data) {
$('#dropdown2div').html(data);
}////////////function html////////
})/////////function ajax//////////
});
</script>
<?php close(); ?>
</p>
</body>
</html>
dropdown_select.php
<?php
require_once('func.inc.php');
connect();
if(isset($_GET['val'])){
$val = $_GET['val'];
$dropdown = $_GET['dropdown'];
}
if($dropdown == '2'){
echo '<select id="dropdown2" name="dropdown2">';
governorateQuery();
echo '</select>';
?>
<script type="text/javascript">
$("#dropdown2").change(function() {
val = $(this).val();
var html = $.ajax({
url: "dropdown_select.php?dropdown=3&val="+val+"",
async: true,
success: function(data) {
$('#dropdown3div').html(data);
}////////////function html////////
})/////////function ajax//////////
});
</script>
} // end if statement
if($dropdown == '3'){
echo '<select id="dropdown3" name="dropdown3">';
specializationQuery();
echo '</select>';
} // end if statement
close();
?>