fixed small bugs, added a table to show the flotte

This commit is contained in:
2026-06-22 16:40:20 +02:00
parent fe90e2d766
commit 608cceec18
3 changed files with 46 additions and 2 deletions
+31
View File
@@ -55,3 +55,34 @@ document.getElementById("trier").addEventListener("click", function () {
});
afficherEquipe(triee);
});
const flotte1 = [
{ modele: "Renault Kangoo", immatriculation: "AB-123-CD", km: 45200 },
{ modele: "Peugeot Partner", immatriculation: "EF-456-GH", km: 78900 },
{ modele: "Citroën Berlingo", immatriculation: "IJ-789-KL", km: 12300 },
];
function createLign(car) {
const tr = document.createElement("tr");
const tdmodele = document.createElement("td");
tdmodele.textContent = car.modele;
const tdimma = document.createElement("td");
tdimma.textContent = car.immatriculation;
const tdkm = document.createElement("td");
tdkm.textContent = car.km;
tr.append(tdmodele, tdimma, tdkm);
return tr;
}
const flotte = document.getElementById("flotte_tableau");
function afficherFlotte(list) {
flotte.innerHTML = "";
for (const car of list) {
flotte.append(createLign(car));
}
}
afficherFlotte(flotte1);
+1 -1
View File
@@ -1,5 +1,5 @@
async function chargerFlotte() {
const reponse = await fetch("./vehicules.json"); // on demande le fichier
const reponse = await fetch("../vehicules.json"); // on demande le fichier
const vehicules = await reponse.json(); // on le transforme en tableau JS
console.log(vehicules); // pour vérifier
}
+14 -1
View File
@@ -67,12 +67,25 @@
</section>
</div>
<table border=1 class="table">
<thead>
<tr>
<th>Modèle</th>
<th>immatriculation</th>
<th>Km</th>
</tr>
</thead>
<tbody id="flotte_tableau">
</tbody>
</table>
<footer class="footer">
stagiaires rpz echoes
<button type="button" id="theme"> Mode sombre</button>
</footer>
<script src="../equipe.js"></script>
<script src="../contact.js"></script>
<script src="../flotte.js"</script>
<script src="../flotte.js"></script>
</body>
</html>