I have a drop down menu using Twitter Bootstrap and I would like to change my query string that I send to my PHP script according to what I have selected on the drop down menu. 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() {}
}
});
console.log("Click : " + category);say? (after removing var)var categoryis removed, then category really should be set also 5 lines below, unless there is some code we cannot see.catedgorymay be misspelled (seecategory)