formulaire rempli

This commit is contained in:
Valentin CZERYBA 2022-08-05 23:56:26 +02:00
parent 6e04e8b668
commit 11cdca95ea
2 changed files with 20 additions and 9 deletions

View File

@ -165,22 +165,22 @@
<div class="input-group mb-3">
<label class="input-group-text" for="SelectorRoles">Roles</label>
<select class="form-select" id="SelectorRoles">
<option value="admin">Administrateur</option>
<option value="user">Utilisateur</option>
<label class="input-group-text" for="rolesSelector">Roles</label>
<select class="form-select" id="rolesSelector">
<option value="Admin">Administrateur</option>
<option value="User">Utilisateur</option>
</select>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="birthdateUpdate">Date de naissance</span>
<input id="birthdateUpdateInput" type="date" class="form-control" placeholder="Date de naissance" aria-label="Date de naissance" aria-describedby="birthdateUpdate">
<span class="input-group-text" id="birthUpdate">Date de naissance</span>
<input id="birthUpdateInput" type="date" class="form-control" placeholder="Date de naissance" aria-label="Date de naissance" aria-describedby="birthdateUpdate">
</div>
<div class="input-group mb-3">
<label class="input-group-text" for="SelectorStatus">Statut</label>
<select class="form-select" id="SelectorStatus" disabled>
<label class="input-group-text" for="statusSelector">Statut</label>
<select class="form-select" id="statusSelector" disabled>
<option value="-2" selected>Statut</option>
<option value="-1">En cours de suppression</option>
<option value="0">Desactivé</option>

View File

@ -5,10 +5,21 @@ var id = getQuery("id");
if(id.length > 0){
instance.get("users/"+id, {withCredentials: true})
.then(function(response){
var listValue = [ "id", "pseudo", "name", "firstName", "email"];
var listValue = [ "id", "pseudo", "name", "firstName", "email", "birth"];
for (var i=0; i<listValue.length; i++){
document.getElementById(listValue[i]+"UpdateInput").value=response.data[listValue[i]];
}
var listSelector = ["roles", "status"];
for (var i=0; i<listSelector.length; i++){
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
for (var j=0; j<select.length; j++){
if(select[j].value == response.data[listSelector[i]]){
select[j].setAttribute("selected", true);
}
}
}
})
.catch(function(error){