I need to make the checkbox responsive (in .HTML file), i.e on select of checkbox the url of the page should get modified and page should get refreshed. Following is my code, right now the checkboxes are modifying the url but as soon as it is refreshed the loose their state also I need to modify url on uncheck. Please HELP.
var $checkes = $('input:checkbox[name="ch"]').change(function () {
var vals = $checkes.filter(':checked').map(function () {
return this.value;
}).get();
var newurl = document.location.href;
for (k in vals) {
newurl = newurl + "+" + vals[k];
}
document.location.href = newurl;
var i = newurl.lastIndexOf('/');
var checkedOnes = newurl.substr(i + 1).split('+');
var len = checkedOnes.length;
for (var i = 2; i < len; i++) {
document.getElementById(checkedOnes[i]).checked = true;
}
});
Aucun commentaire:
Enregistrer un commentaire