3 changed files with 81 additions and 1 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
{% extends 'admin_template.html' %}{% block 'contenu' %} |
||||
<form id="form" action="{% url "app:admin-distances" %}" method="POST">{% csrf_token %} |
||||
<table class="table"> |
||||
<thead> |
||||
<tr> |
||||
<th scope="col" ></th>{% for row in data %} |
||||
<th scope="col">{{row.zone.nom}}</th>{% endfor %} |
||||
</tr> |
||||
</thead> |
||||
<tbody>{% for row in data %} |
||||
<tr> |
||||
<td>{{row.zone.nom}}</td>{% for col in row.distances %} |
||||
{% if col.class != "table-secondary" %} |
||||
<td class="{{col.class}}"><input type="number" name="{{col.ref}}" onchange="changeHandler(event)" class="form-control" maxlength="2" value="{{col.value}}"></td> |
||||
{% else %} |
||||
<td class="{{col.class}}">{{col.value}}</td> |
||||
{% endif %}{% endfor %} |
||||
</tr>{% endfor %} |
||||
</tbody> |
||||
</table> |
||||
<input id="update" type="submit" value="Valider"> |
||||
<input type="button" value="Reset" onclick="resetForm()"> |
||||
</form> |
||||
<script> |
||||
function resetForm() { |
||||
document.getElementById("form").reset(); |
||||
var inputs = document.querySelectorAll('input'), i; |
||||
for (i = 0; i < inputs.length-2; ++i) { |
||||
inputs[i].parentNode.className = ""; |
||||
} |
||||
} |
||||
|
||||
function changeHandler(evt) { |
||||
evt.target.parentNode.className = "table-warning"; |
||||
} |
||||
</script>{% endblock %} |
||||
Loading…
Reference in new issue