1
I have a search bar here, but how do I search my htmls in my own pc directory?
function executar(){
var tx= document.getElementById('tx').value;
var lista = document.getElementById('ht');
var adicionar= true;
var opt = document.createElement('option');
for(i=0; i <lista.options.length;i++){
if(tx==lista.options[i].value){
adicionar=false;
}
}
if(adicionar==true){
opt.value=tx;
lista.appendChild(opt);
}
}
.ps{ width: 400px;
height: 40px;
margin: 200px auto;
}
#tx{ width: 350px;
height: 40px;
float: left;
font-family: 'Arial';
font-size: 20px;
}
.bt{ width: 30px;
height: 30px;
background-color: #2f4550;
padding: 5px 10px;
cursor: pointer;
}
#tx:focus{ border:2px solid #2f4550;
}
<form class="ps">
<input type="search" id="tx" list="ht" placeholder="pesquisar">
<img src="" class="bt" onclick="executar()">
<datalist id="ht">
<option value="Css"></option>
<option value="Games"></option>
<option value="Html"></option>
<option value="C++"></option>
</datalist>
</form>
You can explain better, it wasn’t very clear. If script adds non-existent options with what was typed in the search, and what else is to do?
– Sam
Yes it memorizes what the user typed
– Elienay Junior
now I wanted another script to search on my own page
– Elienay Junior
"now I wanted another script to search on my own page"... Search what? That part that was not clear.
– Sam
wanted one that I could edit and link my pages
– Elienay Junior
fetch contents from my directory
– Elienay Junior
that when typing something specific in the bar it directs to some link of my pages in my pc directory
– Elienay Junior
is a normal search bar even, only internal search
– Elienay Junior
Okay, but if you leave the page, the datalist will go back to the original state. Soon the script that adds items to the datalist becomes useless.
– Sam
can even take this script there, I just wanted to make a bar to search in my own folder where are my htmls
– Elienay Junior
Put all the details in the question, it avoids staying here in the debating comments, which is very bad.
– Sam
I’m voting to close the question by lack of clarity... if the quality improves I withdraw the vote. Good luck there!
– Sam
You will need Database - Mysql example - and a server-side language - PHP example. You have these tools?
– user60252
I haven’t gotten to this subject yet, for now I’m still studying html / css and a little JS
– Elienay Junior
Would it be possible to just use Mysql?? da to do it with Js??
– Elienay Junior
I guess not, I don’t know
– user60252