/    Sign up×
Community /Pin to ProfileBookmark

Javascript List Search

I know I can use a simple datalist like the w3schools link below but I’m looking for something which is a bit more customizable

https://www.w3schools.com/tags/tag_datalist.asp

What I have is either a datalist or more preferably a JS array {id: 1, text: ‘This is my text’, id: 2, text: ‘second ‘}

I need some code which based on user input will return possible matches in a custom list.

Anyone got anything similar to get me started?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumMar 16.2022 — I know about two plugins that might fit your needs:

https://selectize.dev

https://select2.org
Copy linkTweet thisAlerts:
@kiwisauthorMar 17.2022 — Thanks, I've used select2 before. The issue is both use select tags and with thousands of rows to search the page load times are horrendous.

I was going to use a textbox and a JS function to search an array for matches. Then return a subset of this, maybe the first 10 only?

I'm just now sure how you'd search a JS node of an array against text input

Copy linkTweet thisAlerts:
@SempervivumMar 17.2022 — @kiwis80#1643255
>with thousands of rows to search the page load times are horrendous.

Use ajax and server side filtering:

https://select2.org/data-sources/ajax
×

Success!

Help @kiwis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...