var EntiteGenerale = document.getElementById("TypeEntityId").value;
var Departement = {
1: "Finances et Administration",
2: "Service Logistique Transversale",
3: "Institut de Formation",
4: "Communication, Marketing & Commercial",
5: "Volontariat",
6: "Ressources Humaines",
7: "Service francophone du sang",
8: "Service ECM et DIH",
9: "Service Tracing",
10: "Département Secours"
};
var CentreSecours = {
1: "CG BUTGENBACH BULLINGEN",
2: "CS BLEGNY",
3: "CS BRABANT OUEST",
4: "CS CHARLEROI",
5: "CS HAUTE SENNE",
6: "CS HERSTAL - OUPEYE",
7: "CS TOURNAI",
8: "CS NAMUR",
9: "CS OTTIGNIES",
10: "CS OUGREE",
11: "CS PHILIPPEVILLE",
12: "CS ROCHEFORT",
13: "CS SPA",
14: "CS HESBAYE-CONDROZ",
15: "CS JODOIGNE",
16: "CS LIEGE",
17: "CS LUXEMBOURG",
18: "CS MONS",
19: "CS MOUSCRON"
};
/* Add event parameter to localise value extraction from corresponding
select element */
function DisplayEntiteL(event) {
/* Get current value of TypeEntityId select */
const value = event.currentTarget.value
const entityId = document.getElementById("EntityId");
/* Empty any previous options from EntityId select */
while (entityId.hasChildNodes()) {
entityId.removeChild(entityId.lastChild);
}
/* If value of TypeEntityId is 2 then show Departement items in
entityId select */
if (value === '2') {
for (index in Departement) {
entityId.appendChild(new Option(Departement[index], index));
}
}
/* If value of TypeEntityId is 3 then show CentreSecours items in
entityId select */
else if (value === '3') {
for (index in CentreSecours) {
entityId.appendChild(new Option(CentreSecours[index], index));
}
}
/* Otherwise log to console */
else {
/* entityId.appendChild(new Option('No options')); */
console.log("rien à afficher");
}
}
/* Bind change event via addEventListener() */
document.getElementById("TypeEntityId").addEventListener('change', DisplayEntiteL)
input[type='checkbox'] {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
border: 1px solid rgba(0, 0, 0, 0.1);
width: 15px;
height: 15px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
input[type='radio'] {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
border: 1px solid rgba(0, 0, 0, 0.1);
width: 15px;
height: 15px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
input[type='radio']:checked {
background-color: red;
}
input[type='checkbox']:checked {
background-color: red;
}
input::placeholder {
font-size: 0.7rem;
}
select {
border-radius: 20px;
font-size: 0.8rem;
}
select:focus {
border-color: #ff2400;
outline: 0;
box-shadow: none;
}
<div class="row col-md-12">
<div class="col-md-12">
Votre entité générale :
<select data-val="true" data-val-number="The field TypeEntityId must be a number." data-val-range="The field TypeEntityId must be between 1 and 2147483647." data-val-range-max="2147483647" data-val-range-min="1" data-val-required="Vous devez donner un TYPE d'entité"
id="TypeEntityId" name="TypeEntityId">
<option value="">Sélectionnez une entité générale</option>
<option value="2">Départements & Services centraux</option>
<option value="3">Centre de secours</option>
<option value="4">Section locale (Bruxelles) </option>
<option value="5">Comité Provincial</option>
<option value="6">Relais</option>
<option value="7">SISU</option>
<option value="8">Centre ADA</option>
<option value="9">Maison Croix-Rouge</option>
</select>
<span class="field-validation-valid text-danger" data-valmsg-for="TypeEntityId" data-valmsg-replace="true"></span>
</div>
</div>
<br>
<div class="row col-md-12">
<div class="col-md-12">
Votre entité locale :
<select data-val="true" data-val-number="The field EntityId must be a number." data-val-range="The field EntityId must be between 1 and 2147483647." data-val-range-max="2147483647" data-val-range-min="1" data-val-required="Vous devez donner une ENTITE"
id="EntityId" name="EntityId"><option value="">Sélectionnez une entité locale</option>
</select>
<span class="field-validation-valid text-danger" data-valmsg-for="EntityId" data-valmsg-replace="true"></span>
</div>
</div>