I have a page with filters, being 4 selects, an input search, 2 input date and a submit, I need to keep the data selected after reloading the page.
In other words, I put the data to filter and after clicking the submit and the load page it needs to keep the values of the form as selected before submit.
At first I'm saving in cookie with the code below, but despite saving cookies, I wanted to know if I can decrease this code? Type instead of using a $.cookie
for each input, use one for the whole form.
And also I would like to know how popular the new form with cookie data and if this can not cause me problems it getting stored, can delete cookies after using them?
$(".searchButton").on("click", function () {
$.cookie('frachiseesValue', $("#frachisees_filter").val());
$.cookie('schoolsValue', $("#schools_filter").val());
$.cookie('challengeValue', $("#post_challenges_filter").val());
$.cookie('statusValue', $("#statuses_filter").val());
$.cookie('searchValue', $("#filter_search").val());
$.cookie('startDateValue', $("#startDate").val());
$.cookie('endDateValue', $("#endDate").val());
});
Update