// Araç bilgileri (Marka, Model, Seri, Motor ve Yakıt Tüketimi)
const aracBilgileri = {
“Honda”: {
“Civic”: {
“MK9 TypeR (2015-2017)”: {
“motorlar”: {
“2.0 Type R (310 hp)”: { tuketim: 8.0 },
“1.6 i-DTEC (120 hp)”: { tuketim: 5.0 }
}
},
“MK10 (2017-2020)”: {
“motorlar”: {
“1.5 Turbo (180 hp)”: { tuketim: 6.0 },
“2.0 i-DTEC (160 hp)”: { tuketim: 5.5 }
}
}
},
“CR-V”: {
“2015-2020”: {
“motorlar”: {
“1.6 i-DTEC (160 hp)”: { tuketim: 5.2 }
}
}
}
},
“Volkswagen”: {
“Golf”: {
“MK7 (2012-2019)”: {
“motorlar”: {
“1.6 TDI (115 hp)”: { tuketim: 4.8 },
“2.0 GTI (220 hp)”: { tuketim: 7.2 }
}
}
}
}
};
// Araç marka seçildiğinde model ve seri güncelleme
function aracSecildi() {
let marka = document.getElementById(“marka”).value;
let modelSelect = document.getElementById(“model”);
let seriSelect = document.getElementById(“seri”);
let motorSelect = document.getElementById(“motor”);
let tuketimInput = document.getElementById(“tuketim”);
// Başlangıçta her şeyi temizle
modelSelect.innerHTML = ““;
seriSelect.innerHTML = ““;
motorSelect.innerHTML = ““;
tuketimInput.value = “”;
if (marka) {
// Marka seçildiğinde, markaya ait modelleri ekle
let modeller = Object.keys(aracBilgileri[marka]);
modeller.forEach(model => {
let option = document.createElement(“option”);
option.value = model;
option.textContent = model;
modelSelect.appendChild(option);
});
}
}
// Model seçildiğinde, serileri güncelleme
function modelSecildi() {
let marka = document.getElementById(“marka”).value;
let model = document.getElementById(“model”).value;
let seriSelect = document.getElementById(“seri”);
let motorSelect = document.getElementById(“motor”);
let tuketimInput = document.getElementById(“tuketim”);
// Başlangıçta motor seçeneklerini temizle
seriSelect.innerHTML = ““;
motorSelect.innerHTML = ““;
tuketimInput.value = “”;
if (marka && model) {
// Model seçildiğinde, o modele ait serileri ekle
let seriler = Object.keys(aracBilgileri[marka][model]);
seriler.forEach(seri => {
let option = document.createElement(“option”);
option.value = seri;
option.textContent = seri;
seriSelect.appendChild(option);
});
}
}
// Seri seçildiğinde motor seçeneklerini güncelleme
function seriSecildi() {
let marka = document.getElementById(“marka”).value;
let model = document.getElementById(“model”).value;
let seri = document.getElementById(“seri”).value;
let motorSelect = document.getElementById(“motor”);
let tuketimInput = document.getElementById(“tuketim”);
// Başlangıçta motor seçeneklerini temizle
motorSelect.innerHTML = ““;
tuketimInput.value = “”;
if (marka && model && seri) {
// Seri seçildiğinde, o seriye ait motor seçeneklerini ekle
let motorlar = Object.keys(aracBilgileri[marka][model][seri].motorlar);
motorlar.forEach(motor => {
let option = document.createElement(“option”);
option.value = motor;
option.textContent = motor;
motorSelect.appendChild(option);
});
}
}
// Motor seçildiğinde yakıt tüketimini güncelleme
function motorSecildi() {
let marka = document.getElementById(“marka”).value;
let model = document.getElementById(“model”).value;
let seri = document.getElementById(“seri”).value;
let motor = document.getElementById(“motor”).value;
if (marka && model && seri && motor) {
let tuketim = aracBilgileri[marka][model][seri].motorlar[motor].tuketim;
document.getElementById(“tuketim”).value = tuketim;
}
}
Aracım Ne Kadar Yakar