mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Gère l'affichage dynamique des choix d'ip en fonction du machine_type
Enlève toutes les options au loading de la page si JS activé Ajoute des options quand le machine_type change grâce aux associations machien_type -> ip reçues
This commit is contained in:
parent
1baf52ac6e
commit
d890d4ac1e
1 changed files with 24 additions and 0 deletions
|
@ -38,6 +38,30 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% bootstrap_form_errors domainform %}
|
{% bootstrap_form_errors domainform %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var type_to_ipv4 = {
|
||||||
|
type: [{% for type, iplist in type_to_ipv4.items %}"{{ type }}",{% endfor %}],
|
||||||
|
iplist: [{% for type, iplist in type_to_ipv4.items %}
|
||||||
|
[{% for ip in iplist %} {id:"{{ ip.id }}", ip:"{{ ip.ipv4 }}"},
|
||||||
|
{% endfor %}], {% endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#id_ipv4").html("<option value='' selected='selected'>Choisisez un type de machine d'abord</options>");
|
||||||
|
$("#id_type").change(function() {
|
||||||
|
var val = $(this).val();
|
||||||
|
var options = "<option value='' selected='selected'>Assignation automatique de l'ipv4</option>";
|
||||||
|
for (var i = 0; i < type_to_ipv4.type.length; i++) {
|
||||||
|
if (type_to_ipv4.type[i] == val) {
|
||||||
|
for (var j = 0; j < type_to_ipv4.iplist[i].length; j++) {
|
||||||
|
options += "<option value='"+type_to_ipv4.iplist[i][j].id+"'>"+type_to_ipv4.iplist[i][j].ip+"</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#id_ipv4").html(options)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
Loading…
Reference in a new issue