From d7b5df74be2190e2f87a54b29c59d5b5750d6825 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 18 Jun 2026 15:09:33 +0200 Subject: [PATCH] simulateur de devis --- pages/css/devis.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pages/css/devis.js diff --git a/pages/css/devis.js b/pages/css/devis.js new file mode 100644 index 0000000..6487e7b --- /dev/null +++ b/pages/css/devis.js @@ -0,0 +1,34 @@ +const affichageNb = document.getElementById("nb_vehicules"); +const affichageGéo = document.getElementById("géolocalisation"); +const affichageConso = document.getElementById("consommation"); +const boutonPlus = document.getElementById("plus"); +const boutonMoins = document.getElementById("moins"); +const PRIX_GPS = 30; +const PRIX_CONSOMMATION = 15; +let nbVehicules = 1; +let totalargent = 0; +function mettreAJourGPS() { + affichageNb.textContent = nbVehicules; + affichageGéo.textContent = nbVehicules * PRIX_GPS; +} +function mettreAJourCONSO() { + affichageNb.textContent = nbVehicules; + affichageConso.textContent = nbVehicules * PRIX_CONSOMMATION; +} +function mettreAJourTOTAL() { + affichageNb.textContent = totalargent; + affichageGéo.textContent = totalargent + PRIX_GPS + PRIX_CONSOMMATION; +} +boutonPlus.addEventListener("click", function () { + nbVehicules = nbVehicules + 1; + (mettreAJourGPS(), mettreAJourCONSO()); + if (nbVehicules > 99) { + nbVehicules = nbVehicules - 1; + } +}); +boutonMoins.addEventListener("click", function () { + if (nbVehicules > 1) { + nbVehicules = nbVehicules - 1; + } + (mettreAJourGPS(), mettreAJourCONSO()); +});