Interaction design • webdevelopment • web art • photography : forum : coding : 'Combox with autocomplete'

Combox with autocomplete,sywerd,Sidney, 030612 23:11
Is It possible to have a combox where i can put the firts 2 letters and the list became short. The working in the same way the access combox? I have 302 lines from my db in the listbox .
Re: Combox with autocomplete (I forgot to say that the p… Sidney, 030612 23:30
I forgot to say that the page is in asp
Re: Combox with autocomplete Calm_Pear, 030613 07:46
Hi Sidney,

Check the listbox on this site:
Re: Combox with autocomplete Sidney, 030613 22:25
Calm_Pear, thanks,now i know that it is possible and work nicely, and you can choise from "Starting With" or "Containing".
Very clever...
I couldn't find the code in the site, do you have any clue where to search for the code?

Thank anyway
Re: Combox with autocomplete Calm_Pear, 030614 14:51
What do you mean 'the code'?? view the source:
Just write al available options into the array with asp...
Something like:

Do While Not RecordSet.EOF
tmp = tmp & """" & RecordSet("fieldName") & "",""
tmp = Left(tmp, Len(tmp) - 1 ) 'remove last comma
Maybe Response.Write the string first to see if it's all correct, then Respone.Write it between the
var functionlist = Array(

Let me know if this helps ;-)
Re: Combox with autocomplete Shailesh, 030705 03:47
In ASP, use GetString for about 10x speed improvement. An example is below. The example assumes different option value and name, so you'll have to modify the Javascript code so that it searches through every other option in the array. If your option values and names are the same, you can use a straight call to GetString.

Sub PrintOptionsArray()
' get option names and values for javascript
strsql = "SELECT idfield,namefield FROM tblOptions"
objRS.Open strsql, objCN,adOpenForwardOnly,adLockReadOnly,adcmdtext
If Not objRS.EOF Then
strOptionsList = objRS.GetString ( , ,","&Chr(34),Chr(34)&","&vbCrLf," " )
strOptionsList = Left(strOptionsList,Len(strOptionsList)-3)
End If
Response.write strOptionsList
End Sub

Combined with Javascript:

var JumpWidgetOptions = Array(<% PrintOptionsArray %>);

Note, the example above is not complete, but has enough to give you the idea. Also, if your option names or values contain double-quote characters, you'll either have to modify the query to use a replace function, or use the regular method of looping through the query.
Pages: 1