Search system on the site itself, how to link as many pages and recognize the typed characters

Asked

Viewed 122 times

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?

  • Yes it memorizes what the user typed

  • now I wanted another script to search on my own page

  • "now I wanted another script to search on my own page"... Search what? That part that was not clear.

  • wanted one that I could edit and link my pages

  • fetch contents from my directory

  • that when typing something specific in the bar it directs to some link of my pages in my pc directory

  • is a normal search bar even, only internal search

  • 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.

  • can even take this script there, I just wanted to make a bar to search in my own folder where are my htmls

  • Put all the details in the question, it avoids staying here in the debating comments, which is very bad.

  • I’m voting to close the question by lack of clarity... if the quality improves I withdraw the vote. Good luck there!

  • You will need Database - Mysql example - and a server-side language - PHP example. You have these tools?

  • I haven’t gotten to this subject yet, for now I’m still studying html / css and a little JS

  • Would it be possible to just use Mysql?? da to do it with Js??

  • I guess not, I don’t know

Show 11 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.