Наверно что надо как-то вызвать doload(), но как это сделать правильно я не знаю.(( Да использую библиотеку JsHttpRequest.
Вот код:
<script>
function doload(value){
var req=new JsHttpRequest();
req.onreadystatechange=function(){
if(req.readyState==4)
document.getElementById("result").innerHTML=req.responseText;
}
document.getElementById("select1").value = value;
req.open(null,"/parts/select.php",true);
req.send({country:value});}
</script>
<?php
$q = _query("SELECT country_in,country_out FROM country");
while($f=_fetch($q)){
$sw_country_test.=option(value(win_utf8($f["country_in"])),win_utf8($f["country_in"]));
}
$pp="<select name=\"country\" onchange=\"doload(this.value);\">";
$pp.=$sw_country_test;
$pp.="</select>";
$search =
form(name("out").action("/s/").method("post"),
table(border(0),
tr(no(),
.td(valign("top"),$pp)
.td(valign("top"),div(id("result"),""))
.td(no(),input(id("select1").name("clik_test").type("hidden").value($clik_test)))
.td(no(),input(type("submit").name("find").value("Далее")))
).input(type("hidden").name("action").value("country"))
)
);
?>
select.php
<?php
require("JsHttpRequest.php");
$JsHttpRequest=new JsHttpRequest("windows-1251");
$pp = $_REQUEST["country"];
#MySQL
$db=con_srv_p();
mysql_set_charset('cp1251',$db);
$f=_fetch($q=_query("SELECT * FROM country WHERE country_in='".utf8_win($pp)."'"));
$city=$f["country_out"];
$ar=array();
$q=_query("SELECT * FROM hotel WHERE hotel_country='".$city."' OR hotel_country='".$pp."'");
while($f=_fetch($q)){
$vvv=(string) array_search($f["hotel_city"],$ar);
if($vvv==""){
$html .= input(type("checkbox").name($f["hotel_id"]).checked("N"))." ".font(no(),$f["hotel_city"])."<br>";
array_push($ar,$f["hotel_city"]);
}
}
#close DB
dc_srv($db);
echo $html;
?>