我有一个使用 Twitter Bootstrap 的下拉菜单,我想根据我在下拉菜单中选择的内容更改我发送到我的 PHP 脚本的查询字符串。I have everything in place I believe I just think its an error with the scope as the category will not change when a new drop down menu item is selected and remains constantly fixed at genres.
$('#categoryInputValue').val(""); //Sets the category box to empty
var catedgory = "Genres";
var queryString = 'autocomplete.php?cat=' +catedgory;
console.log("Page Load : " + catedgory);
$('.dropdown-menu a').click( function ()
{
console.log(catedgory = $(this).text()); //Gets the category name from the list item
queryString = 'autocomplete.php?cat=' +catedgory;
$('#dropDownMenu').html(catedgory+' <span class="caret"></span>'); //Changes the drop down menu categories to the selected one and adds the downwards arrow
$('#categoryInputValue').attr("placeholder", catedgory); //Sets the placeholder to equal the category
console.log("Click : " + catedgory);
});
$("#categoryInputValue").autocomplete({
source: queryString,
minLength: 4,
messages: {
noResults: '',
results: function() {}
}
});