Hello All,
I've taken the autosuggest example from the web applications demo and got it working nicely on one table in my database.
What I'm trying to accomplish now is modifying the .ajax page to work across multiple tables.
The xbasic code (taken from the .ajax page)
***********************************************
<%a5
dim action as c = default ""
dim dbf_folder as c
dbf_folder = _A5_Aliases.get("PathAlias.ADB_Path")
DIM tableFilename as c
tableFilename = a5_removetrailingbackslash(dbf_folder) + chr(92) + "compser.dbf"
if action = "getserviceList" then
dim service as c = default ""
if service <> "" then
dim tbl as p
tbl = table.open(tableFilename)
dim itbl as p
itbl = tbl.order("serv","left(serv," + len(service)+")=" + s_quote(service))
result = tbl.record_content_get("alltrim(serv)")
tbl.close()
'just take the first 15 entries in the list
result = word(result,1,crlf(),15)
result = alltrim(remove_blank_lines(result))
'convert the |||| delimited string into a Javascript array of the form ['item1','item2']
result = *for_each(x,"['"+strtran(strtran(x,"'","\'"),"||||","','")+"']",result)
'convert the crlfs to commas so that we have a Javascript array of arrays.
result = "["+rtrim(strtran(result,crlf(),","),",")+"]"
?"serviceSuggest.populateList("+result+");"
end if
else if action = "getFilteredserviceList" then
dim service as c = default ""
dim servicename as c = default ""
if service <> "" .and. servicename <> "" then
dim tbl as p
tbl = table.open(tableFilename)
dim itbl as p
itbl = tbl.order("servid","left(servid," + len(service)+")=" + s_quote(service) + " .and. serv = " + quote(servicename))
result = tbl.record_content_get("alltrim(servid) + '||||' + alltrim(serv)")
tbl.close()
'just take the first 15 entries in the list
result = word(result,1,crlf(),15)
result = alltrim(remove_blank_lines(result))
'convert the |||| delimited string into a Javascript array of the form ['item1','item2']
result = *for_each(x,"['"+strtran(strtran(x,"'","\'"),"||||","','")+"']",result)
'convert the crlfs to commas so that we have a Javascript array of arrays.
result = "["+rtrim(strtran(result,crlf(),","),",")+"]"
?"serviceFilteredSuggest.populateList("+result+");"
end if
tbl.close()
end if
function jsEscape as c (txt as c)
jsEscape = stritran(txt,"'","\'")
jsEscape = stritran(jsEscape,crlf(),"\n")
end function
%>
*******************************************
I've been looking at the if..then..else function and tried modifying but just can get it to work. What i need to do is the following
1) Take the input
2) search fields across multiple tables.
Please can someone give me some pointers what would be the best way to approach this?
I've been pulling my hair out tryin all kinds of combinations.
Many Thanks
I've taken the autosuggest example from the web applications demo and got it working nicely on one table in my database.
What I'm trying to accomplish now is modifying the .ajax page to work across multiple tables.
The xbasic code (taken from the .ajax page)
***********************************************
<%a5
dim action as c = default ""
dim dbf_folder as c
dbf_folder = _A5_Aliases.get("PathAlias.ADB_Path")
DIM tableFilename as c
tableFilename = a5_removetrailingbackslash(dbf_folder) + chr(92) + "compser.dbf"
if action = "getserviceList" then
dim service as c = default ""
if service <> "" then
dim tbl as p
tbl = table.open(tableFilename)
dim itbl as p
itbl = tbl.order("serv","left(serv," + len(service)+")=" + s_quote(service))
result = tbl.record_content_get("alltrim(serv)")
tbl.close()
'just take the first 15 entries in the list
result = word(result,1,crlf(),15)
result = alltrim(remove_blank_lines(result))
'convert the |||| delimited string into a Javascript array of the form ['item1','item2']
result = *for_each(x,"['"+strtran(strtran(x,"'","\'"),"||||","','")+"']",result)
'convert the crlfs to commas so that we have a Javascript array of arrays.
result = "["+rtrim(strtran(result,crlf(),","),",")+"]"
?"serviceSuggest.populateList("+result+");"
end if
else if action = "getFilteredserviceList" then
dim service as c = default ""
dim servicename as c = default ""
if service <> "" .and. servicename <> "" then
dim tbl as p
tbl = table.open(tableFilename)
dim itbl as p
itbl = tbl.order("servid","left(servid," + len(service)+")=" + s_quote(service) + " .and. serv = " + quote(servicename))
result = tbl.record_content_get("alltrim(servid) + '||||' + alltrim(serv)")
tbl.close()
'just take the first 15 entries in the list
result = word(result,1,crlf(),15)
result = alltrim(remove_blank_lines(result))
'convert the |||| delimited string into a Javascript array of the form ['item1','item2']
result = *for_each(x,"['"+strtran(strtran(x,"'","\'"),"||||","','")+"']",result)
'convert the crlfs to commas so that we have a Javascript array of arrays.
result = "["+rtrim(strtran(result,crlf(),","),",")+"]"
?"serviceFilteredSuggest.populateList("+result+");"
end if
tbl.close()
end if
function jsEscape as c (txt as c)
jsEscape = stritran(txt,"'","\'")
jsEscape = stritran(jsEscape,crlf(),"\n")
end function
%>
*******************************************
I've been looking at the if..then..else function and tried modifying but just can get it to work. What i need to do is the following
1) Take the input
2) search fields across multiple tables.
Please can someone give me some pointers what would be the best way to approach this?
I've been pulling my hair out tryin all kinds of combinations.
Many Thanks
Comment