Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Additional search terms based on initial search term

  • 21-11-2014 12:15pm
    #1
    Banned (with Prison Access) Posts: 1,279 ✭✭✭


    Hi All,

    There is a website which I sometimes visit which hosts user uploaded content. I can't link to the site and that tells you the sort of site that it is! Many people on boards will have heard of it. It isn't niche.

    At any rate the site has an ajaxy search input box and also a very clever additional search terms suggestion box that is not a text box but a group of links; this appears underneath the search box and clicking on one of the new suggestions adds the term to the users search.

    I had a look in Firebug but I can't see what they are calling and I wonder if anyone has any idea.

    It is similar to the suggested forums feature on boards where if you search for rugby it gives a link to the rugby forum.


Comments

  • Registered Users Posts: 6,240 ✭✭✭hussey


    Yes, I build one for my last job.
    You need some kind of service to respond with the data coming back
    function getSearchSuggestions(SS, A){
    	$.ajax({
    		type:"GET",url:searchSuggestionsUrl+A,
    		dataType:"json",
    		cache:false,
    		success:function(B){
    			var D="<ul>";
    			var E="";
    			for(var C in B.results)
    			{
    				E+="<li><a href=\"javascript:void(0);\">"+B.results[C].name+"</a></li>"
    			}
    			D+=E+"</ul>";
    			if (E == ""){ D="";}
    			$(SS).html(D);
    			if($(SS).text()!=""){
    				$(SS).show(300)
    			}
    		}
    	})
    }
    
    Very basic construction of a <ul><li><a href .. link to search>
    and SS is the searchSuggestions data area and A is what was typed in


Advertisement