28 lines
654 B
JavaScript
28 lines
654 B
JavaScript
const options = document.querySelectorAll('input[name=rating]');
|
|
const submitRating = document.getElementById('submit_rating');
|
|
|
|
let empty = true;
|
|
options.forEach(option => {
|
|
empty &&= !option.checked;
|
|
});
|
|
|
|
if (empty) {
|
|
submitRating.innerText = 'Enthalten';
|
|
|
|
options.forEach(option => {
|
|
option.addEventListener('change', () => {
|
|
submitRating.innerText = 'Speichern';
|
|
});
|
|
});
|
|
}
|
|
|
|
document.getElementById('reset_rating').addEventListener('click', () => {
|
|
options.forEach(option => {
|
|
if (option.attributes.getNamedItem('checked') !== null) {
|
|
option.attributes.removeNamedItem('checked');
|
|
}
|
|
});
|
|
|
|
submitRating.innerText = 'Enthalten';
|
|
});
|