Keep Selected Value Of Drop Down List After Page Refresh
I have a button to filter a list based on the selections from several drop-down values. However I am running into an issue whereby once the button is clicked, the page refreshes an
Solution 1:
You can use the HTML5 localStorage api (http://www.w3schools.com/html/html5_webstorage.asp)
Example for your case:
$(document).ready(function() {
// On refresh check if there are values selectedif (localStorage.selectVal) {
// Select the value stored
$('select').val( localStorage.selectVal );
}
});
// On change store the value
$('select').on('change', function(){
var currentVal = $(this).val();
localStorage.setItem('selectVal', currentVal );
});
Hope this helps. Keep me posted.
Post a Comment for "Keep Selected Value Of Drop Down List After Page Refresh"