Javascript tooltip tooltip

I want to get from the user:

keywords = prompt("Input keywords separated by commas", "");


I have many different strings stored in a SQLite database that can prompt the user what to enter. Let's say you have an array or list of these strings. How would you code this Javascript hint? Are there some features or code snippets for this feature?

I would like it to work similarly here . When you start typing, you get a hint of possibilities. There is only one drawback: you cannot enter more lines, separated by commas. Here, this function works on a lot of lines.

Is the prompt () function suitable for this purpose? You can use a different user input method.



source to share

2 answers

You cannot customize the inline request () javascript method.

I know you haven't checked jQuery, but it would be easier to use a library to implement this kind of behavior.

You will need to create your own dialog system using perhaps jQuery UI Dialogs . They have the ability to make it modal so that the UI locks until the dialog is closed.

The jQuery UI Dialog will not block javascript execution like the prompt does. You may need to execute code when you close the dialog. This answer shows a way to easily implement this.

Finally, jQuery UI autocomplete gives an example of how to use it for multiple values ​​on the same input. They use comma separator, but I think you could change the example of working with spaces: jQuery UIAutocomplete Multiple values



You cannot use any custom functions with hint ().

You'd better create <input type="text"/>

and bind the whole thing to a button so that the data is sent whenever the user clicks on it or presses the enter key. Then code it to get the autosugges value whenever the user enters a new character.

You should have a look at the jQuery UI autocomplete component (it also works with multiple lines as input), you will also need to set up a server-side script to contain the possibly incomplete line as input, and output a possible match list back to the browser.



All Articles