You are viewing limited content. For full access, please sign in.

Question

Question

How to create a search bar with dynamic propositions

asked on November 8, 2017

Hi Team,

 

I would like to create a search bar with dynamic propositions.

 

Someone know how to do under Laserfiche Form?

Thanks in advance.

 

Regards

 

0 0

Replies

replied on November 8, 2017 Show version history

It depends on how you have everything configured, but something similar is possible with the built-in functionality.

If you have a database table that contains all of the possible "suggestions" then you can set the Single Line field to use that table/column as a Lookup and remove the "When" condition; this will retrieve all of the rows, and it will not auto-populate the field (unless there is only one row in the table).

With that configuration, it will pull all of the possible options from that column in the database table, and as the person types it will narrow the list to anything containing the letter combination in the field.

The only catch is that it matches across entire words, not just the beginning.

For example,

If your table has the following options

  • Apple
  • Banana
  • Orange
  • Strawberry
  • Watermelon

 

Typing "e" will narrow it down to

  • Apple
  • Orange
  • Strawberry
  • Watermelon

 

Typing "ra" will narrow it down to

  • Orange
  • Strawberry

 

Typing "an" will narrow it down to

  • Banana
  • Orange

 

And so on

 

2 0
replied on November 9, 2017

Hi Jason,

 

Thank you very. I'm going to try.

0 0
replied on November 9, 2017 Show version history

It's working. Thank you very much.

 

But the user can write a word outside from the list ; how can I check if this word is in my list?

"eet" is in my list

 

"eer" is not in my list. The user should not submit the form.

0 0
replied on November 9, 2017 Show version history

If you want to make it so the have to choose something from your list and still allow them to type, then you'll need to do the following:

  1. Add a hidden Dropdown field with the same lookup rule
  2. Use JavaScript to confirm that what they typed is one of the options available in the hidden field

You can do this many different ways, but my preferred method is to create a Custom Validator and assign it to the field they are typing into; you can find an example of the custom validation here.

The example shows how to prevent duplicate entries, but you can replace the validation function with one that searches for the typed value in the dropdown and returns true/false (found/not found).

The reason I recommend the custom validator is that it will prevent form submission if it marks the field as invalid. Any other approach would require additional steps to stop the user from submitting the form with an invalid entry in the field.

1 0
replied on November 13, 2017

Hi Jason,

 

I'm not pretty good with javascript. I'm trying to decrypte the code but I dont really understand.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.