I tested the below script on a demo page that does not use CMS. The script is in the index.php file and it works fine.
<form method="get" action="">
<input id="label_search" type="text" value="" maxlength="40" name="inputText"/>
</form>
<script type="text/javascript">
var options = {
script:"includes/autosuggest.php?json=true&",
varname:"input",
minchars: 2,
delay: 200,
json:true,
shownoresults:false,
maxresults:15,
timeout: 5000
};
var as_json = new bsn.AutoSuggest('inputText', options);
</script>
Now I want to use the same code in the Wordpress template file. But nothing happens. It looks like the script is not running at all.
I use a convenient URL and set custom permalinks to /% category% /% postname%. Maybe there is something to say?
I know that bsn.AutoSuggest_2.1.3.js is running because the test "alert ('hello") in the file runs when the page loads.
What could be wrong?
This is my WP code:
sl_startpage.php:
<?php
get_header(); ?>
<div id="myArea">
<?php
include_once('includes/storeLocator/sl_header.php');
?>
</div>
<?php
get_footer();
?>
This is the (simple) code in sl_header.php:
<div id="sl-header">
<form method="get" action="">
<input id="label_search" type="text" value="" maxlength="40" name="product_search"/>
</form>
</div>
<script type="text/javascript">
var options = {
script:"includes/autosuggest.php?json=true&",
varname:"input",
minchars: 2,
delay: 200,
json:true,
shownoresults:false,
maxresults:15,
timeout: 5000
};
var as_json = new bsn.AutoSuggest('product_search', options);
</script>
Any suggestions anyone?
, :
http://www.brandspankingnew.net/archive/2007/02/ajax_auto_suggest_v2.html