Archived
1
0

Added JavaScript to restore selected options (easier than making it work

in Mustache).
This commit is contained in:
2016-05-26 00:28:35 +02:00
parent f2decbf6a1
commit c807857e27
5 changed files with 22 additions and 4 deletions

18
js/frs.js Normal file

@ -0,0 +1,18 @@
document.addEventListener("DOMContentLoaded", function(event) {
var all_selects = document.getElementsByTagName('select');
for (var i in all_selects) {
if (!all_selects.hasOwnProperty(i)) {
continue;
}
var xsel = all_selects[i];
var xvalue = xsel.dataset.value;
//console.log('Value of %o = %o', xsel, xvalue);
// Walk all options, compare to desired value and set if matches
for (var o in xsel.options) {
if (xsel.options[o].value == xvalue) {
xsel.selectedIndex = o;
break;
}
}
}
});