Есть вот такой код (позаимствованный):
HTML |
var dr = document; var div_selectr; var reqr = Create(); function Razdel() { div_selectr = "podrazdel"; var c = dr.getElementById('id_razdel').value; query = "id_razdel="+c; Request(query); } function Create(){ if(navigator.appName == "Microsoft Internet Explorer"){ reqr = new ActiveXObject("Microsoft.XMLHTTP"); }else{ reqr = new XMLHttpRequest(); } return reqr; } function Request(query) { reqr.open('post', 'selectsr.php' , true ); reqr.onreadystatechange = Refresh; reqr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); reqr.send(query); } function Refresh() { var c,d; c = reqr.readyState; if( c == 4 ) { d = reqr.responseText; dr.getElementById(div_selectr).innerHTML = d; } } |
PHP |
<? |
PHP |
include_once("config.php"); |
HTML |
function Razdel(id) { div_selectr = "podrazdel_"+id; var c = dr.getElementById('id_razdel_'+id).value; query = "id_razdel="+c+'&sel='+id; Request(query); } |
PHP |
<?php |
PHP |
<?php |
HTML |
<?php echo razdel(1) ?> <div id="podrazdel_1" ></div> <?php echo razdel(2) ?> <div id="podrazdel_2" ></div> <?php echo razdel(3) ?> <div id="podrazdel_3" ></div> |
HTML |
<div id="podrazdel_1" > <select> <option value='0'>- Выберите подраздел -</option> </select> </div> |