LyndonOHRC
Programmer
I have a suggest list that is populated when a certain number of characters have been typed. This is the only triggering mechanism I've been able to find.
My customer has asked if instead the AJAX call can be made after they stop typing for two or three seconds. Is this possible? This would result in fewer calls to the server side code.
Thanks in advance for any suggestions!
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
My customer has asked if instead the AJAX call can be made after they stop typing for two or three seconds. Is this possible? This would result in fewer calls to the server side code.
Code:
function FoalNameSuggestList(inputElem,TableData) {
var urlVar=document.getElementById(inputElem).value;
if (urlVar.length>3 [COLOR=red]/*And keyboard is idle for two seconds ???*/[/color]){
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else{alert("Your browser does not support XMLHTTP!");}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
var users = eval(trim(xmlhttp.responseText));
var str = '<ul class="suggestList">';
for ( var recno in users ) {
str += '<li onmouseover="HighlightSuggestList(this.id)" onmouseout="noHighlightSuggestList(this.id)" class="listItem" id="'+users[recno].OBN+'" onclick="putFoalData( \'' +users[recno].OBN+ '\',\'' +TableData+ '\')">'+users[recno].HoresName+'</li>';
}
str +='</ul>';
document.getElementById(TableData).innerHTML = str;
document.getElementById(TableData).style.display='block';
document.getElementById(TableData).onblur=function() {setOnblur(TableData)};
document.getElementById(TableData).onmouseover=function() {setFocus(TableData)};
}
else{
document.getElementById(TableData).innerHTML = '';
document.getElementById(TableData).style.display='none';
}
}
var randomString = new Date().getTime();
xmlhttp.open("GET","NoMenu/GetChart.cfm?NoCache="+randomString+"&searchTerm="+urlVar+"&Horse="+TableData,true);
xmlhttp.send(null);
}
}
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey