Dia 33
This commit is contained in:
46
Practicas/Practicas JS/DOM 6/js/main.js
Normal file
46
Practicas/Practicas JS/DOM 6/js/main.js
Normal file
@@ -0,0 +1,46 @@
|
||||
function calculaTotales() {
|
||||
let nDias = document.getElementById("nDias").value;
|
||||
let destino = document.getElementById("destino").value;
|
||||
let costeVuelo = document.getElementById("costeVuelo");
|
||||
let costeHotel = document.getElementById("costeHotel");
|
||||
let tasasViaje = document.getElementById("tasasViaje");
|
||||
let costeAlquilerCoche = document.getElementById("costeAlquilerCoche");
|
||||
let costeTotal = document.getElementById("costeTotal");
|
||||
|
||||
let PVPHOTEL;
|
||||
let PVPALQUILERCOCHE =
|
||||
parseInt(nDias) >= 7 ? 40 : parseInt(nDias) <= 3 ? 80 : 60;
|
||||
let IVA = 1.21;
|
||||
|
||||
let tasas = 0;
|
||||
switch (destino) {
|
||||
case "500":
|
||||
tasas = 50;
|
||||
PVPHOTEL = 90;
|
||||
break;
|
||||
case "1000":
|
||||
tasas = 100;
|
||||
PVPHOTEL = 110;
|
||||
break;
|
||||
case "1200":
|
||||
tasas = 120;
|
||||
PVPHOTEL = 80;
|
||||
break;
|
||||
}
|
||||
if (nDias >= 12) {
|
||||
tasas = 0;
|
||||
}
|
||||
|
||||
let vuelo = parseInt(destino);
|
||||
let hotel = nDias * PVPHOTEL;
|
||||
let alquilerCoche = nDias * PVPALQUILERCOCHE;
|
||||
let total = parseFloat((vuelo + hotel + tasas + alquilerCoche) * IVA).toFixed(
|
||||
2
|
||||
);
|
||||
|
||||
costeVuelo.value = vuelo;
|
||||
costeHotel.value = hotel;
|
||||
tasasViaje.value = tasas;
|
||||
costeAlquilerCoche.value = alquilerCoche;
|
||||
costeTotal.value = total;
|
||||
}
|
||||
Reference in New Issue
Block a user