I have a live search facility that narrows down results in a table as you type – all works fine.
I now want to use a dropdown to populate the search field (text box) as i plan to have the search field hidden. – I have done this using the following:
$('#filter').change(function(){
filterby = $('#filter').val();
$("input#SearchBox").val(filterby);
});
The problem i have is that when you choose an option from the dropdown it does populate the text field but the results do not update unless i click in the text box and hit a key (space bar for example).
I assume it requires keyboard input and thus only updates if i add a space at the end but is there a way of changing the above code to get the searchbox to recognise it automatically?
Thanks for your help
You need to use
triggerto make it recognize that the input is different. The live search you are using probably useskeyuporkeypress.If
trigger('keyup')or ‘keypress’ doesn’t work, you might also try it with ‘change’.