function $(id) { return document.getElementById(id); } function Ajax(method, url, id) { if(window.XMLHttpRequest) { req = new XMLHttpRequest(); } else { req = new ActiveXObject("Microsoft.XMLHTTP"); } req.onreadystatechange = function() { if(req.readyState == 4 && req.status == 200) { $(id).innerHTML = req.responseText; } } req.open(method, url, true); req.send(null); } document.onreadystatechange = function() { $("select_country").onclick = function() { //Отправляем запрос для получения списка стран Ajax("GET", "set.php?country=all", "country"); } //ответ выводит следующее: //<span class="country set_1">Украина</span> //<span class="country set_2">Россия</span> //<span class="country set_3">Беларусь</span> //Используя что отправляем очередной запрос для получения списка регионов var countryList = document.getElementsByClassName("country"); for(i = 0; i < countryList.length; i++) { countryList[i].onclick = function() { Ajax("GET", "set.php?country=" + parseInt(this.className.replace(/\D+/g, '')), "region"); } } //тут еще кусок скрипта который уже подгружает города по выбранному региону } Sketched the work of the script) Now the question! How to make a script to get a list of regions and then a list of cities having dynamically loaded html?
Something like live () in jQuery, but jQuery is not a question!