function getSearchResult(key, dlName) {
key = key.trim();
if (key == '' ) {
return false;
}
//如果key中包含字母,则不进行后台查询
if (isExistLetter(key)) {
return false;
}
if(selectedflg==1){
return false;
}
var dataList = document.getElementById(dlName);
//清空当前数据
clearDatalist(dlName);
// Create a new XMLHttpRequest.
var request = new XMLHttpRequest();
// Handle state changes for the request.
request.onreadystatechange = function (response) {
if (request.readyState === 4) {
if (request.status === 200) {
// Parse the JSON
var jsonOptions = JSON.parse(request.responseText);
// Loop over the JSON array.
jsonOptions.forEach(function (item) {
// Create a new <option> element.
var option = document.createElement('option');
// Set the value using the item in the JSON array.
option.value = item.search_name;
// Add the <option> element to the <datalist>.
dataList.appendChild(option);
});
} else {
return false;
}
}
};
// Set up and make the request.
var url = gethostUrl() + 'Tel/commonSearch'
request.open('GET', url + '?key=' + encodeURI(key), true);
request.send();
}
function datalistchange(key, dlName) {
document.getElementById(dlName).innerHTML = key;
treeReturn();
}