During some research I stumbled upon the following thread where someone introduced using a repeater to have a dynamic auto suggest field (one that actually shows suggestions based on what you type, instead of always the same suggestions): Auto-Suggest
I liked the approach and figured it could be improved a bit more. Just wanted to share what I built in case it might be helpfor for others.
What it does:
[ul]
[li]Uses a list of all countries in the world as an example. Simply change the repeater data to something that makes sense for your application.[/li][li]Limited to showing 5 items. Change that via the paging options of the repeater.[/li][li]It finds any items that contain the text you type in, no matter where (start, middle, end of string).[/li][li]The typed text is highlighted in bold.[/li][li]The suggestions are not case sensitive, but the shown suggestions adapt to show upper or lower case letters.[/li][/ul]
I like it. Though you do need to make sure your repeater disappears when you clear the search field.
What Iâd love to ask is (Because Iâve been doing something quite similar myself in a recent project) if you think there is a way to, once there are options displayed below the search field, tab through the possible matches using the cursor keys.
Since you asked for improvements :), you could make it significantly faster by doing the following:
Set the filter just once, in the OnPageLoad handler, but change it to this:
[[Item.ListEntry.toLowerCase().indexOf(LVAR_SearchText.toLowerCase())>=0 && LVAR_SearchText != ââ]]
(Thatâs two single quotes at the end.) The bolded part above causes the repeater to return no rows when the search field is blank. So now you donât have to hide and show the repeater conditionally. Filters hang around once you create them, so if itâs the same each time, you only have to define it once.
In the OnTextChange handler, re-trigger the filter specified above by performing an Update command that does nothing. (In the update command, just set the rule to [[true]] and donât specify any column to change.) The OnTextChange handler will look like this:
This is great! Is anyone else running into problems with the text field not showing any formatting changes when published? Axure shows my changes, but when published it defaults back to the original style. I donât see any overriding style rules and feel a bit perplexed about whatâs going on. Any help would be greatly appreciated.
Thanks for following up! I see the problem now. Iâm seeing that the text field changes to a smaller input field with an âxâ at the end when the âInput Typeâ is set to âSearchââdoes that sound right?
If so, the Text Field widget is a form-type widget which turns into a real HTML form element in Axure RPâs HTML output. This widget has limited styling options because its formatting is largely controlled by, and rendered differently in each browser. Thus, theyâre generally difficult to get cross-browser consistency. For example, youâll see that Chrome and Safari outputs the text field differently, while Firefox renders it as is.
If you want the text field to show up as WYSIWYG, youâll have to style it individually (e.g. layer with Rectangle widget), or change the âInput Typeâ to âTextâ. Hopefully this helps!
Hi . I need a working prototype for search autocomplete just like any other search autocomplete sites. Was wondering if you have any good ones that i can take reference from. Am currently a UX/UI designer.
The first post at the top of this thread has a .rp file that you can reference. If you browse the forums, there are some other posts with sample .rp files that demo the predictive search/autocomplete functionality:
Hi ⌠This is a very interesting and useful thread - thanks! I am an Axure beginner, though - what would be a good way for me to begin to develop some useful knowledge of the conditional logic language? Iâm trying to learn from the shared .rp files - is there a better way? Thanks!!!
If you have any questions about implementing something in your project, please donât hesitate to start a new thread on the forum or even email our support team at <support@axure.com>. HTH!
why did you create two variables for the search field. A global variable âSearchTermâ and a local variable for the filter rule âLVAR_SearchTextâ?
I would like to understand the logic behind this. Anyone knows the answer?
The âLVAR_SearchTextâ local variable and the âSearchTermâ global variable both reference the same thing: text on the SearchField widget, so it mightâve just been personal preference. You can test this by replacing LVAR_SearchText with SearchTerm and youâll see that you get the same results.