Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Auto completing a form from and to a mysql database

by perlfan (Vicar)
on Oct 15, 2020 at 14:39 UTC ( #11122862=note: print w/replies, xml ) Need Help??

in reply to Auto completing a form from and to a mysql database

If you're using a JS library, there is a good chance it supports an "autocomplete" widget. These work by using some event (e.g., "keyup" or whatever) to automatically send an asynchronous request to the backend with the current state of the search bar. The response will be handled by your Perl application and should return a list of entries to populate the dropdown list. Conceptually, this is straigtforward. However if you choose when to query the list poorly (e.g., too early) then it can quickly become both a user experience issue and a potential resource spike issue on your server. So on the server side, you just need a trad request handler given a "search term" (state of the input field). On the client side is where you do all the fancy stuff. You can get fancy on the server side with caching and whatnot, but I'd focus on getting it right on the client side first. Note: I have a forever hobby website that I maintain that includes a custom search. I've resisted putting in autocomplete, mainly because all the interesting stuff required is on the front end and I prefer the interesting stuff to be on the back end. So I have thought about it, just never executed on it.
  • Comment on Re: Auto completing a form from and to a mysql database

Replies are listed 'Best First'.
Re^2: Auto completing a form from and to a mysql database
by Dazz45X (Novice) on Oct 15, 2020 at 15:47 UTC
    Thank you perlfan,

    Yes I think Fletch has given me something to go on re the widgets. There is a search on the site for anything that is listed which works quite well but operates on the flat files. The mysql database I have been working on seperately for about 35 years :) , always knew I'd have to try and integrate it, so now is the time. I did wonder about the impact on the server as potentially with 60000 items to sift through 3 times it might be that the user could have typed it in quicker? although I have no knowledge of the 'quickness' of mysql databases.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11122862]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2021-03-05 10:32 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (109 votes). Check out past polls.