Stimulated by:
"I have a hidden text field which contains a list of my customers (it’s lengthy!). I have another field where a user types the name of the customer. I’d like my app to display a list of possible customers as the user types the name of the customer. I’d like it to work in the same way as typing something into the URL field of a web browser in that a field containing possible customers is displayed just below the text field the user is typing the customer in that the user can could click a customer name in the below field and have it populate the text field above. Ideally, the list field would dynamically resize itself vertically to show only the list of possible customers as the user types.
I’m not sure how to accomplish this. Can anyone provide some code on how to achieve this?"
and
"Hi Richmond,
Thank you the sample stack! Although it works, could you expand the code so that the list of customers updates accordingly when the user presses the delete/backspace key?"
------
Code: Select all
on keyUp
end keyUp
on keyDown KP
put KP after fld "ZZZ"
put empty into fld "xlist"
put fld "ZZZ" into XYZ
put the number of chars in XYZ into KKK
put 1 into LYNE
repeat until line LYNE of fld "slist" is empty
put char 1 to KKK of line LYNE of fld "slist" into ZLIST
if ZLIST contains XYZ then
put line LYNE of fld "slist" & cr after fld "xlist"
end if
add 1 to LYNE
end repeat
end keyDown
on backspaceKey
delete the last char of fld "ZZZ"
put empty into fld "xlist"
put fld "ZZZ" into XYZ
put the number of chars in XYZ into KKK
put 1 into LYNE
repeat until line LYNE of fld "slist" is empty
put char 1 to KKK of line LYNE of fld "slist" into ZLIST
if ZLIST contains XYZ then
put line LYNE of fld "slist" & cr after fld "xlist"
end if
add 1 to LYNE
end repeat
end backspaceKey