Welcome to WebmasterWorld Guest from 54.144.243.34

Forum Moderators: open

Ajax auto suggestion search from database

   
10:04 am on Nov 9, 2011 (gmt 0)

5+ Year Member



I am implementing a Ajax auto suggestion search from database. I find an example from [roscripts.com ]. I have not problem with the php part about search from database, but i got a problem from the search from, i added a listerner to input tag, but it still not auto suggest anyword when i type any of word, Could any one help me, Thanks.




<html>
<head>
<title>roScripts - Ajax auto-suggest</title>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="lib/prototype.js" type="text/javascript"></script>
<script src="src/scriptaculous.js" type="text/javascript"></script>
<script src="src/unittest.js" type="text/javascript"></script>

<script src="lib/builder.js" type="text/javascript"></script>
<script src="src/controls.js" type="text/javascript"></script>
<script src="src/effects.js" type="text/javascript"></script>

<link rel="stylesheet" href="css/style.css" type="text/css" />

</head>
<body>

<div id="container">

<form method="post" action="response.php">
<label for="testinput">Search</label><br />
<input type="text" id="search" name="search" autocomplete="off" class="input" value="" #nkeyup="autoSuggest##;" /><br />
<div id="update" st#le="display:none;position:relative;"></div>
<input type="image" name="register" class="submit-btn" src="http://www.roscripts.com/images/btn.gif" alt="submit" title="submit" />
</form>

<script type="text/javascript" language="javascript" charset="utf-8">

function autoSuggest##{
new Ajax.Autocompleter#'search','update','response.php', { tokens: ','} #;
Autocompleter.show##;

}

</script>

</div>

</body>
</html>
5:22 pm on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I think something may be screwy in your editor, what are all the pound # signs? Verify that is not being placed in your page code.

Off the top, you may just have a simple error here (IGNORING the pound signs):


autocomplete="off" class="input" value="" #nkeyup="autoSuggest##;" />

That's supposed to be onkeyup, is it that way in your page?
9:47 pm on Nov 9, 2011 (gmt 0)

5+ Year Member



when i post my thread, this server edit my code, should not have the ##. i post it again

<html>
<head>
<title>roScripts - Ajax auto-suggest</title>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="lib/prototype.js" type="text/javascript"></script>
<script src="src/scriptaculous.js" type="text/javascript"></script>
<script src="src/unittest.js" type="text/javascript"></script>

<script src="lib/builder.js" type="text/javascript"></script>
<script src="src/controls.js" type="text/javascript"></script>
<script src="src/effects.js" type="text/javascript"></script>

<link rel="stylesheet" href="css/style.css" type="text/css" />

</head>
<body>

<div id="container">

<form method="post" action="response.php">
<label for="testinput">Search</label><br />
<input type="text" id="search" name="search" autocomplete="off" class="input" value="" onkeyup="autoSuggest();" /><br />
<div id="update" style="display:none;position:relative;"></div>
<input type="image" name="register" class="submit-btn" src="http://www.roscripts.com/images/btn.gif" alt="submit" title="submit" />
</form>

<script type="text/javascript" language="javascript" charset="utf-8">

function autoSuggest(){
new Ajax.Autocompleter('search','update','response.php', { tokens: ','} );
Autocompleter.show();

}

</script>

</div>


</body>
</html>
2:09 pm on Dec 1, 2011 (gmt 0)

5+ Year Member



Have you tried jQuery's autocomplete widget?

look here: [jqueryui.com...]
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month