Suggestions:
Here's the code that makes this work. First, the JavaScript:
var xmlHttp;
function showHint(str) {
if (str.length==0) {
document.getElementById("txtHint").innerHTML="";
return;
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Your browser does not support HTTP Request. This application require HTTP Request support.");
return;
}
var url="/ajax.ul?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject(handler) {
var objXMLHttp=null;
// Firefox, Opera 8.0+, Safari
if (window.XMLHttpRequest) {
objXMLHttp=new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
And here's the User Language that responds to the XMLHttpRequest:
Begin
%q is string len 20
%hint is LongString
%d is Object StringList
%s is Fixed
%x is Float
%d = New
Text to %d
Alan
Alana
Alex
Alexa
Alice
Alister
Amanda
Anna
Brittany
Cinderella
Cindy
Daisy
Dave
Diana
Doris
Elisha
Ellen
Eve
Evita
Gunda
Hege
Helena
Inga
Ingrid
Iris
Johanna
Kitty
Latoya
Linda
Liza
Nina
Ophelia
Petunia
Raquel
Sunny
Tove
Uma
Vicky
Violet
Wenche
Xena
End Text
%q = $UpCase($Web_Parm('q'))
* Look up hints if the input parm is gt null.
If $Len(%q) Then
%hint = ''
%s = 1
%x = %d:Locate(%q,%s,1,$Len(%q),1)
Repeat While %x
%hint = %hint with ' ' with %d:Item(%x)
%s = %x + 1
%x = %d:Locate(%q,%s,1,$Len(%q),1)
End Repeat
End If
* Set output to "no suggestion" if no hint were found
If %hint eq '' Then
Html Data No Suggestion
Else
Html Data {%hint}
End If
End