Search inside a Search | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Search inside a Search

I am having major issue with a code. I am new to learning this stuff and I am trying to get my search bars able to action a search inside a search and where possible to be able to just type in a search on the same bar. Is this possible? sorry for the Long Code https://code.sololearn.com/WLU59Rz1Y7Ve/#html

25th Jul 2017, 2:10 PM
Ethan “Rammster” Taylor
Ethan “Rammster” Taylor - avatar
6 Answers
+ 2
To have dropdown options show as you are searching, use the list attribute for your input and assign it to your <datalist> tag's ID. Fill this datalist with <option> tags. <input list="languages"> <datalist id="languages"> <option value="JavaScript"> <option value="HTML"> <option value="CSS"> </datalist> Here's some more info: https://www.w3schools.com/tags/att_input_list.asp In your situation, you will want the datalist to fill dynamically in JavaScript. So, make some code that is similar to your search (or make this part of the main search), then instead of having it make content appear, have it create option tags. var elem= document.createElement("option"); elem.value = //The search result var datalist = document.getElementById("languages"); datalist.appendChild(elem); //You will want it inside a loop or function that is called for each result. //Also, you will want to remake the list each time ou change the input, i.e. on the event keypressup I see, however, that you already have your own style of dropdown created. If you want to keep using it, running a search code function to remove existing searches then fill it with new div or p tags, being called on each keypress like above.
25th Jul 2017, 8:59 PM
James
James - avatar
+ 2
So search once and get some results, then search for new keywords within those results? It shouldn't be too hard, but for us to explain you would need to show us how your main search is structured. I don't see why you'd need it, though--just add the extra keyword to the end of the input. Or do you perhaps mean for it to autocomplete your input? Or search for through things besides website content?
25th Jul 2017, 1:05 PM
James
James - avatar
+ 2
paste the code in code Playground and then share it here.. it is so messy here
25th Jul 2017, 2:09 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
Code added to original thread. :D Thanks
25th Jul 2017, 1:46 PM
Ethan “Rammster” Taylor
Ethan “Rammster” Taylor - avatar
0
Try that link if it works
25th Jul 2017, 2:11 PM
Ethan “Rammster” Taylor
Ethan “Rammster” Taylor - avatar
0
Hi James. I am trying to set up a site so that I can search inside a search so have drop down functions when I click an option, or alternatively just be able to type in key words on the search bar itself. still having the options show though. Thanks all :D
25th Jul 2017, 2:12 PM
Ethan “Rammster” Taylor
Ethan “Rammster” Taylor - avatar