core: add macro that selects/unselect all checkbox

This commit is contained in:
2019-04-22 14:59:32 +02:00
parent 96e33815f5
commit 2ae10ee2fb
3 changed files with 36 additions and 10 deletions

View File

@@ -132,3 +132,18 @@
<span class="disabled">{% trans %}Next{% endtrans %}</span>
{% endif %}
{% endmacro %}
{% macro select_all_checkbox(form_id) %}
<script type="text/javascript">
function checkbox_{{form_id}}(value) {
list = document.getElementById("{{ form_id }}").getElementsByTagName("input");
for (let element of list){
if (element.type == "checkbox"){
element.checked = value;
}
}
}
</script>
<button type="button" onclick="checkbox_{{form_id}}(true);">{% trans %}Select All{% endtrans %}</button>
<button type="button" onclick="checkbox_{{form_id}}(false);">{% trans %}Unselect All{% endtrans %}</button>
{% endmacro %}