I have ajax in those highlighted functions, java script dose not wait until the request comes from the server goes ahead and execute the other commands I don't won't that!
I am a newbie to java script...
function putthedataback() {
for (var i = 0; i < year.length; i++) {
var a = i + 1;
year1fun(year[i],a);
cc1fun(cc[i],a);
tp1fun(tp[i],a);
document.getElementById("year" + a).value = "" + year[i];
document.getElementById("cc" + a).value = "" + cc[i];
document.getElementById("tp" + a).value = "" + tp[i];
document.getElementById("du" + a).value = "" + du[i];
document.getElementById("dd" + a).value = "" + dd[i];
document.getElementById("ns" + a).value = "" + ns[i];
document.getElementById("fv" + a).value = "" + fv[i];
}
}
ajax one function
code
function year1fun(value, x) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById("cc" + x).innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "yearselectionchanged.php?q=" + value, true);
xmlhttp.send();
}