millennium Posted May 13, 2008 Posted May 13, 2008 I can not get my search suggest going. I am at wits end. I've gotten a div to pop up but it is tiny and contains nothing. Here is my code. I've moved it around many many times trying to find a working solution. go to www.laserfusers.com if you want to see how it acts for yourself. SEARCHSUGGEST.PHP //Make sure that a value was sent. if (isset($_GET['search']) && $_GET['search'] != '') { //Add slashes to any quotes to avoid SQL problems. $search = addslashes($_GET['search']); //Get every page title for the site. $sql = "select * from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS . " p on pd.products_id = p.products_id WHERE p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and pd.products_name like('%" . tep_db_input($_GET['keywords']) . "%') LIMIT 15"; $suggest_query = tep_db_query($sql); while($suggest = tep_db_fetch_array($suggest_query)) { //Return each page title seperated by a newline. echo $suggest['suggest'] . "\n"; } } JAVASCRIPT <script language="JavaScript" type="text/javascript"> //Gets the browser specific HtmlHttpRequest Object function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your Browser needs to be upgraded"); } } // XmlHttpRequest Object var searchReq = getXmlHttpRequestObject(); // search suggest function function searchSuggest() { if (searchReq.readyState == 4 || searchReq.readyState == 0) { var str = escape(document.getElementById('txtSearch').value); searchReq.open("GET", 'searchsuggest.php?search=' + str, true); searchReq.onreadystatechange = handleSearchSuggest; searchReq.send(null); } } //Called when the AJAX response is returned. function handleSearchSuggest() { if (searchReq.readyState == 4) { var ss = document.getElementById('search_suggest') ss.innerHTML = ''; var str = searchReq.responseText.split("\n"); for(i=0; i < str.length - 1; i++) { //Build our element string. This is cleaner using the DOM, but //IE doesn't support dynamically added attributes. var suggest = '<div onmouseover="java script:suggestOver(this);" '; suggest += 'onmouseout="java script:suggestOut(this);" '; suggest += 'onclick="java script:setSearch(this.innerHTML);" '; suggest += 'class="suggest_link">' + str[i] + '</div>'; ss.innerHTML += suggest; } } } //Mouse over function function suggestOver(div_value) { div_value.className = 'suggest_link_over'; } //Mouse out function function suggestOut(div_value) { div_value.className = 'suggest_link'; } //Click function function setSearch(value) { document.getElementById('txtSearch').value = value; document.getElementById('search_suggest').innerHTML = ''; } </script> <form id="frmSearch" action="http://www.laserfuser.com/advanced_search_result.php"> <input type="text" id="txtSearch" name="keywords" alt="Search Criteria" onkeyup="searchSuggest();" autocomplete="off" /> <input type="submit" id="cmdSearch" value="Search" alt="Run Search" /> <div id="search_suggest"> </div> </form> thank you for any help you can give. Quote
BlindingLight Posted January 11, 2009 Posted January 11, 2009 :D :D Hello! I'm wondering how you got it to work? Which version did you use? Ed. Quote
BlindingLight Posted January 29, 2009 Posted January 29, 2009 I can not get my search suggest going. I am at wits end. I've gotten a div to pop up but it is tiny and contains nothing. Here is my code. I've moved it around many many times trying to find a working solution.go to www.laserfusers.com if you want to see how it acts for yourself. Hey you? Are you alive? Well, I don't have a solution yet... but I have good IDEA of what is making this code not to work for us. STS! Yep... just try disabling this module and you will see that the AJAX Search Suggest starts working. There is something we need to declare under MODULE/sts_inc but I don't know what and where! I believe that it doesn't know where yo pit the information... the javascript says var oscSearchSuggest = new OSCFieldSuggest('txtSearch', 'includes/search_suggest.xsl', 'searchsuggest.php'); but is this the problem? I don't know... or maybe is the fact that in the root folder we have a SearchSuggest.php file and STS doesn't recognize it or something. Anyone? does anyone have any idea??? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.