select.php
<?php
$db = mysql_connect ("localhost", "root", "");
mysql_query ("set character_set_client='cp1251'");
mysql_query ("set character_set_results='cp1251'");
mysql_query ("set collation_connection='cp1251_general_ci'");
mysql_select_db("cars",$db);
?>
<script src="JsHttpRequest.js"></script>
<!– Здесь мы подключили библиотеку. А теперь пишем функцию, которую назовем doload() –>
<script>
function doload(value){
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4) document.getElementById("result").innerHTML=req.responseText;}
req.open(null,"select2.php",true);
req.send({country:value});}
</script>
<form action="sript.php" method="POST">
<select name="country" onchange="doload(this.value);">
<option value="">–Выберите марку–
<?php
$sql = mysql_query ("SELECT DISTINCT brand FROM t1");
while ($new_brand = mysql_fetch_array($sql))
echo "<option value=".'"'.$new_brand['brand'].'"'.">".$new_brand['brand']."";
?>
</select>
<br><br>
<div id="result"></div>
<br><br>
<input type="submit" value="Отправить">
</form>
select2.php
<?php
$db = mysql_connect ("localhost", "root", "");
mysql_select_db("cars",$db);
require("JsHttpRequest.php");
$JsHttpRequest=new JsHttpRequest("windows-1251");
switch($_REQUEST["country"]):
case "Mitsubishi":
$html="<select name=\"provider\" id=\"provider\">
<option value="no_action">–Выберите модель–
$sql = mysql_query ("SELECT DISTINCT model FROM t1 WHERE brand = 'Mitsubishi'");
while ($new_model= mysql_fetch_array($sql))
echo "<option value=".'"'.$new_model['model'].'"'.">".$new_model['model']."";
</select>";
break;
case "Suzuki":
$html="<select name=\"provider\" id=\"provider\">
<option value="no_action">–Выберите модель–
$sql = mysql_query ("SELECT DISTINCT model FROM t1 WHERE brand = 'Suzuki'");
while ($new_model = mysql_fetch_array($sql))
echo "<option value=".'"'.$new_model['model'].'"'.">".$new_model['model']."";
</select>";
break;
case "Hyundai":
$html="<select name=\"provider\" id=\"provider\">
<option value="no_action">–Выберите модель–
$sql = mysql_query ("SELECT DISTINCT model FROM t1 WHERE brand = 'Hyundai'");
while ($new_model = mysql_fetch_array($sql))
echo "<option value=".'"'.$new_model['model'].'"'.">".$new_model['model']."";
</select>";
break;
default: $html=null;
endswitch;
echo $html;
?>