Added JavaScript to restore selected options (easier than making it work
in Mustache).
This commit is contained in:
parent
f2decbf6a1
commit
c807857e27
18
js/frs.js
Normal file
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
@ -29,7 +29,7 @@
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="./js/frs.js" charset="utf-8"></script>
|
||||
{{> mdl_content_foot}}
|
||||
{{> mdl_foot}}
|
||||
{{> html_foot}}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
|
||||
<!-- https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 -->
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select">
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select" data-value="{{value}}">
|
||||
<option value=""></option>
|
||||
<option value="DE">Germany</option>
|
||||
<option value="UK">United Kingdom</option>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
|
||||
<!-- https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 -->
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select">
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select" data-value="{{value}}">
|
||||
<option value=""></option>
|
||||
<option value="EUR">Euro - €</option>
|
||||
<option value="USD">US Dollar - $</option>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label">
|
||||
<!-- https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 -->
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select">
|
||||
<select id="{{field_id}}" name="{{field_id}}" {{#required}}required{{/required}} size="1" class="mdlext-selectfield__select" data-value="{{value}}">
|
||||
<option value=""></option>
|
||||
<option value="http://schema.org/Confirmed">Confirmed</option>
|
||||
<option value="http://schema.org/Cancelled">Cancelled</option>
|
||||
|
Reference in New Issue
Block a user