mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-29 09:52:36 +02:00
Simplify a JS function. (#371)
This commit is contained in:
parent
bfdcf31438
commit
bb77fdbe3e
2 changed files with 8 additions and 19 deletions
|
@ -1,18 +1,7 @@
|
|||
// Add scripts to select all or non of the checkboxes in the add_bill form
|
||||
function selectall()
|
||||
{
|
||||
var els = document.getElementsByName('payed_for');
|
||||
for(var i =0;i<els.length;i++)
|
||||
{
|
||||
els[i].checked=true;
|
||||
}
|
||||
}
|
||||
function selectnone()
|
||||
{
|
||||
var els = document.getElementsByName('payed_for');
|
||||
for(var i =0;i<els.length;i++)
|
||||
{
|
||||
els[i].checked=false;
|
||||
}
|
||||
}
|
||||
|
||||
// Utility to select all or none of the checkboxes in the add_bill form.
|
||||
function selectCheckboxes(value){
|
||||
var els = document.getElementsByName('payed_for');
|
||||
for(var i = 0; i < els.length; i++){
|
||||
els[i].checked = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<label class="col-3" for="payed_for">{{ _("For whom?") }}</label>
|
||||
<div class="controls col-9">
|
||||
<ul id="payed_for" class="inputs-list">
|
||||
<p><a href="#" id="selectall" onclick="selectall()">{{ _("Select all") }}</a> | <a href="#" id="selectnone" onclick="selectnone()">{{_("Select none")}}</a></p>
|
||||
<p><a href="#" id="selectall" onclick="selectCheckboxes(true)">{{ _("Select all") }}</a> | <a href="#" id="selectnone" onclick="selectCheckboxes(false)">{{_("Select none")}}</a></p>
|
||||
{% for key, value, checked in form.payed_for.iter_choices() %}
|
||||
<p class="form-check"><label for="payed_for-{{key}}" class="form-check-label"><input name="payed_for" type="checkbox" {% if checked %}checked{% endif %} class="form-check-input" value="{{key}}" id="payed_for-{{key}}"/><span>{{value}}</span></label></p>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue