Trying an advanced search on the datalist
I have created a datalist like so:
<datalist id=attractions>
<option value="India Agra Taj Mahal">
<option value="India Delhi Red Fort">
<option value="India Agra Red Fort">
<option value="India Jaipur Jal Mahal">
<option value="India Mathura Sheesh Mahal ">
</datalist>
<input id =places type=text list=attractions>
So when I type India Agra
in the textbox the option values which will start with India Agra
ie only two (1st and 3rd)
but if I type India Mahal
it will be unable to search for anything. I would want to be returned the answers: 1, 4 and 5. they contain all the two words in order (India and Mahal)
Is there some way to enable such a search more contextually rather than by the exact terms.
What else can be thought of
If I search Indiaahal
then also it should give those places which has "India" and "ahal" contained in order. So it should show the outputs like both "India Agra Taj Mahal", "India Jaipur Jal Mahal" and "India Mathura Sheesh Mahal"
I believe:
- The solution proposed in the links below do not seem to correctly do what I want. My question is not about "contains" but more than just contains. It is about contains fragments at different locations.
- The solution given by @yash Shukla is close to what I was looking for.