Permalink
Browse files

Added jQuery Autocomplete function to search box

  • Loading branch information...
1 parent f8f93d5 commit e63cb78d92eaad79d74b8ed0b4848eb5dd58bbc3 @gburton committed Aug 3, 2012
@@ -0,0 +1,21 @@
+<?php
+/*
+ Copyright (c) 2012 Club osCommerce www.clubosc.com
+
+ Released under the GNU General Public License
+*/
+
+require_once("includes/application_top.php");
+
+$autocomplete_value = tep_db_input(strtolower($_GET["term"]));
+
+$query = tep_db_query("SELECT products_name FROM products_description WHERE LOWER(products_name) LIKE '%$autocomplete_value%' AND language_id = '" . (int)$languages_id . "'");
+
+for ($x = 0, $numrows = tep_db_num_rows($query); $x < $numrows; $x++) {
+ $row = tep_db_fetch_assoc($query);
+
+ $products[$x] = array("label" => $row["products_name"]);
+}
+
+echo json_encode($products);
+?>
@@ -150,4 +150,10 @@ function tep_db_prepare_input($string) {
return $string;
}
}
+
+
+ function tep_db_fetch_assoc($db_query) {
+ return mysql_fetch_assoc($db_query);
+ }
+
?>
@@ -37,7 +37,7 @@ function execute() {
' <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_SEARCH_BOX_TITLE . '</div>' .
' <div class="ui-widget-content infoBoxContents" style="text-align: center;">' .
' ' . tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get') .
- ' ' . tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: 75%"') . '&nbsp;' . tep_draw_hidden_field('search_in_description', '1') . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', MODULE_BOXES_SEARCH_BOX_TITLE) . '<br />' . MODULE_BOXES_SEARCH_BOX_TEXT . '<br /><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><strong>' . MODULE_BOXES_SEARCH_BOX_ADVANCED_SEARCH . '</strong></a>' .
+ ' ' . tep_draw_input_field('keywords', '', 'class="searchbox" size="10" maxlength="30" style="width: 75%"') . '&nbsp;' . tep_draw_hidden_field('search_in_description', '1') . tep_hide_session_id() . tep_image_submit('button_quick_find.gif', MODULE_BOXES_SEARCH_BOX_TITLE) . '<br />' . MODULE_BOXES_SEARCH_BOX_TEXT . '<br /><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><strong>' . MODULE_BOXES_SEARCH_BOX_ADVANCED_SEARCH . '</strong></a>' .
' </form>' .
' </div>' .
'</div>';
@@ -44,6 +44,16 @@
<script type="text/javascript" src="ext/jquery/bxGallery/jquery.bxGallery.1.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="ext/jquery/fancybox/jquery.fancybox-1.3.4.css" />
<script type="text/javascript" src="ext/jquery/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
+
+<<script type="text/javascript">
+$(document).ready(function() {
+ $( ".searchbox" ).autocomplete({
+ source: "autocomplete_search.php",
+ minLength: 3
+ });
+});
+</script>
+
<link rel="stylesheet" type="text/css" href="ext/960gs/<?php echo ((stripos(HTML_PARAMS, 'dir="rtl"') !== false) ? 'rtl_' : ''); ?>960_24_col.css" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<?php echo $oscTemplate->getBlocks('header_tags'); ?>

0 comments on commit e63cb78

Please sign in to comment.