I am currently using - http://code.drewwilson.com/entry/autosuggest-jquery-plugin for an autosuggest on my site. I have limited the number of choices to 3.
This is the autosuggest code:
<script type="text/javascript">
$(document).ready(function() {
$("input[id=category]").autoSuggest("http://localhost:8888/bl/pages_mx/category_1.php",
{selectedItemProp: "name", selectedValuesProp: "value", searchObjProps: "name",
minChars: 1, matchCase: false, selectionLimit: 3});
});
</script>
The categories the visitor can choose is taken from a table within the MYSQL database. I can now successfully see the suggestions when I begin to type in potential categories!
The 2 values that are queried from the 'category' table are - category_ID and name.
My question is, once the user has chosen their 1,2 or 3 choices, how can I get the category_ID in 3 different variables in php, or in an array?
The closest I have got to help on their discussion forum is by using this code:
var arr = $(".as-values").val().split(",");
But from there, I have no idea how to implement this?
I have tried using an explode function to split the CSV using this:
<?php if($_POST['category_submit']){ ?>
<script type="text/javascript">
var arr = $(".as-values").val().split(",");
var exploded = arr.split(',');
var category_1=exploded[0];
var category_2=exploded[1];
var category_3=exploded[2];
print (category_1);
</script>
<?php } ?>
But nothing seems to print when I press submit?
Any help would be hugely appreciated.
Many thanks!
But nothing seems