Код: Выделить всё
function statequery (theabbrev,thestate) {
if (abbrev.value.length > 0) {
enabledataentry();
const xhttp = new XMLHttpRequest();
xhttp.onload = function(){
var x = 0;
var statearray = JSON.parse(this.responseText);
if (statearray.length > 0){
stateabbrev.innerHTML=statearray[x].abbrev;
statename.innerHTML=statearray[x].statename;
pci.value=statearray[x].pci;
pop.value=statearray[x].pop;
radiobuttons = document.getElementsByName('stateradio');
for (var x=0; x < radiobuttons.length; x++){
if (radiobuttons[x].id === statearray.region) {
radiobuttons[x].checked=true;
break;
}
}
}
}
xhttp.open("GET", "statesearch.php?abbrev="+theabbrev, true);
xhttp.send();
}
}
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/791 ... php-dynami
Мобильная версия