I am writing a small script that will query a database for a title and whilst you enter your title it brings back suggestions.
I have found an example and managed to create one as below:
<head>
<title>Match Form/title>
<script type="text/javascript" src="jquery.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript">
$(document).ready(function()
{
$("#course").autocomplete("get_title_list.php", {
width: 260,
matchContains: true,
mustMatch: true,
selectFirst: false
});
$("#course").result(function(event, data, formatted) {
$("#course_val").val(data[1]);
});
});
</script>
</head>
That then works and allows to print out my result on the page, my next task is to have multiple text boxs along multiple titles and allow someone to search the database and then return the results to the allocated box.
I know id need to assign each box an ID and then select that id in the jquery which is where i am struggling.
Any help would be greatly appreciated!
Instead of an ID, change the text boxes to classes. Something like this should work with the boxes having the class “course”: