diff --git a/assets/js/app.js b/assets/js/app.js index fc7c539..ce75569 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,5 +1,6 @@ import './external_links'; import './message_icons'; +import './forms'; import '../sass/app.scss'; diff --git a/assets/js/forms.js b/assets/js/forms.js new file mode 100644 index 0000000..4161467 --- /dev/null +++ b/assets/js/forms.js @@ -0,0 +1,11 @@ +// For labels to update their state (css selectors based on the value attribute) +document.addEventListener('DOMContentLoaded', () => { + document.querySelectorAll('input').forEach(el => { + if (el.type !== 'checkbox') { + el.setAttribute('value', el.value); + el.addEventListener('change', () => { + el.setAttribute('value', el.value); + }); + } + }); +}); \ No newline at end of file