Creating an auto-suggest field with jQuery |
[eluser]hi8is[/eluser]
I am having the same trouble - outside of code igniter. The auto suggest works - it just doesn't fill in my form when you click on an auto suggest item. PHP Code: <?php // Datebase varibles $db_host = "localhost"; $db_user = "user"; $db_pass = "pass"; // Esstablish connect to MySQL database $con = mysql_connect( $db_host, $db_user, $db_pass); if(!$con) die('Could not connect: ' . mysql_error() ); mysql_select_db("mydb", $con); if(isset($_POST['queryString'])) { $queryString = $_POST['queryString']; if(strlen($queryString) >0) { $query = "SELECT DISTINCT english as english from cats where english LIKE '$queryString%'"; $result = mysql_query($query) or die("There is an error in database please contact [email protected]"); while($row = mysql_fetch_array($result)){ echo '<li>'.$row[english].'</li>'; } } } ?> It returns results and shows them - so I know that the PHP is not the issue. The jQuery: [removed] function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#search').val(thisValue); $('#suggestions').hide(); } [removed] Again - the results are shown but when I get down to the fill(thisValue) function - it doesn't do anything upon clicking a value. Here is my form HTML: <form action="results.php" method="get" name="searchForm"> <input name="search" id="search"> <a href="#" class="clickHere">*click here to post a new or used car part for sale - <u>it’s free.</u></a> <input name="" value="" type="submit" class="searchBtn"/> <div class="suggestionsBox" id="suggestions" style="display: none;"> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> </form> It'd be great if someone gets us over the goal line - I share your frustration. If I figure anything out, I'll let you know. =( Help - please. =) The site in question is www.car-parts-now.info/aman/index2.php |
Welcome Guest, Not a member yet? Register Sign In |