-1
<form class="pesquisa">
<input type="search" class="texto" list="historico" placeholder="Pesquisar gêneros ..." />
<img src="imagem/lupa.jpg" class="btn" onclick="executar()">
<datalist id="historico">
<option value = "Indie"> </option>
<option value = "Rock"> </option>
</datalist>
</form>
<script>
function excecutar()
{
var texto=document.getElementById/('texto').valueOf;
var lista=document.getElementById('historico');
var adicionar=true;
var opt= document.createElement('option');
for(i=0; i <lista.option.lengh;i++){
if(texto==lista.option[i].value){
adicionar=false;
}
}
if(adicionar==true){
opt.value=texto;
lista.appendChild(opt);
}
}
</script>
It is a page with musical genres and I want you to search the content of the same page, similar to the anchor but the difference and you will have search option.
The problem is that although it shows the fill options in the search it does not perform the search, nothing appears.
Explain your question better, the datalist itself is already an auto complete, so I understood in your code is that if there is not what was typed, the code should enter the new value in the list? I was confused.
– ElvisP
Not really, I just want him to search the words and redirect to the corresponding content. I used the option of showing the suggestion of answers in the search, only to facilitate in the search. Even selecting the options it does not search the content.
– Talita Almeida
But search the content that is where? in some element? database? another page? which method of sending data to the search you want to use?
– ElvisP
Search on own page equal when using id for anchor. The content will be on the html page where the music will be, and then search and on the same page.
– Talita Almeida
To search on the same page, it will be a page with a lot of content and therefore it needs the search, it is the same id that is used to search on the same page but I want it to have how to write in the search and to search in the same page and that is something that I am not getting.
– Talita Almeida
checks that the contents of this page are equal, https://www.jqueryscript.net/demo/Search-Keyword-Highlighting-Plugin-With-jQuery-Highlite/
– ElvisP
It is similar to the one you sent but I want when writing word it leads to the part of the page with the content searched. Because I will make a single page for the genre music and there will be some generos and in the research needs that when writing the genre it send to the part with that.
– Talita Almeida