A mystery hits me !
I display with a loop many shipping services available for a given order on a page containing all my orders.
{% for serv in account.services %}
<div class="service">
<label class="form-check-label" for="service{{order.pk}}"><small>{{serv}}</small></label>
{% if forloop.first %}
<input class="form-check-input" type="radio" name="service{{order.pk}}" value="{{serv.pk}}" ismulti="{{serv.is_multiparcel}}" checked>
{% else %}
<input class="form-check-input" type="radio" name="service{{order.pk}}" value="{{serv.pk}}" ismulti="{{serv.is_multiparcel}}">
{% endif %}
{% if order.base_subtotal > serv.insurance_from %}
<div class=" form-text text-danger insur-alert{{order.pk}}">Assur. appliquée car € HT sup. à {{serv.insurance_from}}</div>
{% endif %}
{% if order.weight > serv.max_weight %}
<div class="form-text badge bg-danger" name="weight-alert">Poids commande > max. service {{serv.max_weight}} kg</div>
<script>
disableCheckCauseWeight("service{{ order.pk }}", "{{serv.pk}}");
</script>
{% endif %}
</div>
{% endfor %}
One of these services can be selected with a radio button and is identified by 2 prameters : service{{order.pk}}
and {{serv.pk}}
.
Both of them are well displaying in my html code:
Later in my code, for each loop, I call a JS function for disabling the given service if the order’s weight is higher than the weight accepted by the service.
But, {{serv.pk}}
isn’t sent to disableCheckCauseWeight()
function, despite it’s well displayed above in value="{{serv.pk}}"
.
A console log shows well service{{order.pk}}
but not {{serv.pk}}
. I tried with other values like {{order.pk}}
or “tintin” or any other variable, and it’s ok.
Why do I have this issue with {{serv.pk}}
?