Hi Max,
I have a Ckeckbox group and I want to have the possibility to "select all". How can I do that?
Can you help me?
Greetings
Paul
You need to use some javascript code in a JavaScript view:
document.querySelector("input[name='checkoboxes-name']").forEach(check => {
check.checked = true
})
this code should run when your select all checkbox or button is clicked
Hi Max,
I have this simple form with your javascript, but nothing changed. What is the problem and what do I wrong?
Paul
the code should be inside an event listener:
document.querySelector("#id").addEventListener("click", e => {
document.querySelector("input[name='checkoboxes-name']").forEach(check => {
check.checked = true
})
})
where #id is the id of the field to be clicked, you need to change this based on your requirements
Hi max,
I have tried all kind of triggers etc..
Can you please send me a working example how to use javascript te change the checkboxes.
Paul
I tested the following code and is working:
document.addEventListener("DOMContentLoaded", function (event) {
document.querySelector("[name='checkbox_2']").addEventListener("change", e => { // checkbox_2 is the name of the master checkbox
document.querySelectorAll("input[name='checkboxes_3[]']").forEach(check => { // checkboxes_3[] is the name of the other checkboxes
Nui.Checkbox.getInstance(check.closest(".nui.checkbox")).toggle()
})
})
})
I have also added "Select All" to the list of Listener actions which can be fired on triggers