backup
This commit is contained in:
40
ajax_workshop_1/index.js
Normal file
40
ajax_workshop_1/index.js
Normal file
@@ -0,0 +1,40 @@
|
||||
function showHint(str) {
|
||||
if (str.length === 0) {
|
||||
document.getElementById("txtHint").innerHTML = "";
|
||||
} else {
|
||||
let xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var uic = document.getElementById("txtHint")
|
||||
uic.innerHTML = this.responseText;
|
||||
}
|
||||
};
|
||||
xmlhttp.open("GET", "gethint.php?q=" + str, true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
}
|
||||
|
||||
function showHintSelect(str) {
|
||||
if (str.length === 0) {
|
||||
document.getElementById("txtHint").innerHTML = "";
|
||||
} else {
|
||||
let xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (this.readyState === 4 && this.status === 200) {
|
||||
let select = document.getElementById("resultsSelectionBox")
|
||||
let names = this.responseText.split(',');
|
||||
for (let i = 0; i<names.length; i++) {
|
||||
let opt = document.createElement('option');
|
||||
opt.value = names[i];
|
||||
opt.innerHTML = names[i];
|
||||
select.appendChild(opt);
|
||||
}
|
||||
let hint = document.getElementById("txtHint")
|
||||
hint.innerHTML = this.responseText;
|
||||
}
|
||||
};
|
||||
xmlhttp.open("GET", "gethint.php?q=" + str, true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user