Hi,

Ive built an ajax search for my site that works in a very similar fashion to google suggest....with the results appearing automatically below as the user types in to the search box.

Ive made it that so if the user deletes their search term then the box containing the search results is set to display none, making it dissapear. This is done by the bit of code starting if(search_term == '') {
below:

Code JavaScript:
function search_yes() {
    createRequest();
       ********search is the input box********* 
  	var search = document.getElementById("search");
       *********search container is the div that the seach results sit in***
  	var CON = document.getElementById("search_container");
   	var search_term = search.value;
*******search_list is the un-oredered list
   	var search_list = document.getElementById("search_list");
   	[B]if(search_term == '') { 
   	 CON.style.display = "none";[/B]
     while(search_list.firstChild) {
   	 	search_list.removeChild(search_list.firstChild);
   	 }
   	}
   	var url = "search.php?search=" + escape(search_term);
   	request.open("GET", url, true);
    request.onreadystatechange = handle_search;
    request.send(null);
   }
It all works fine but i noticed that if i try another search immediately after this the previous search results were still there....so i tried to remedy this by removing all the li elements at the same time the search results to display none ( in the same if statement)

Now this kinda worked. You can search again with a different search term and the old search terms are gone but if you try and search the same search term again then no results are shown.

Any ideas as to why this would happen or suggestions of another way of removing the list elements would be more than welcome.

If anyone wants the code for the googlesuggest esque type search then post back and i'll post a solution once this last little problem is sorted out