diff --git a/@ b/@ deleted file mode 100644 index c4053f7..0000000 --- a/@ +++ /dev/null @@ -1,37 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - - //const imieSelect = document.getElementById('imie'); - - let usersData = []; - - imieSelect.addEventListener('focus', function() { - fetch('php/gget.php') - .then(response => response.json()) - .then(data => { - /* - usersData = data; - imieSelect.innerHTML = ""; - data.forEach(dane => { - const option = document.createElement('option'); - option.value = dane.id; - option.textContent = dane.imie + " " + dane.nazwisko; - imieSelect.appendChild(option); - }); -*/ - - console.log(data); - }) - .catch(error => console.error('Error fetching data:', error)); - }); -/* - imieSelect.addEventListener('change', function() { - const selectedId = imieSelect.value; - const selectedPerson = usersData.find(dane => dane.id == selectedId); - if (selectedPerson && selectedPerson.photo) { - photoDisplay.src = 'data:image/jpeg;base64,' + selectedPerson.photo; - } else { - photoDisplay.src = ''; - } - }); -*/ -}); diff --git a/index.html b/index.html index 771e794..01c2444 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,8 @@ Całodobowa stacja paliw - + + @@ -43,6 +44,16 @@ + +
+

Orientacyjny koszt paliwa

+ + + + +
+ + diff --git a/js/get.js b/js/get.js index 9b8d735..dca9b96 100644 --- a/js/get.js +++ b/js/get.js @@ -1,35 +1,42 @@ +const fuelType = document.getElementById('fuel-type'); + +const cena = document.getElementById("cena"); + +let usersData = []; + document.addEventListener('DOMContentLoaded', function() { - const imieSelect = document.getElementById('imie'); - const photoDisplay = document.createElement('img'); - photoDisplay.style.width = "200px"; - photoDisplay.style.height = "auto"; - document.getElementById('prawy').appendChild(photoDisplay); + fetch('php/get.php') + .then(response => response.json()) + .then(data => { + usersData = data; - let usersData = []; + data.forEach(row => { + const option = document.createElement('option'); + option.value = row["nazwa"]; + option.textContent = row["nazwa"]; + fuelType.appendChild(option); - imieSelect.addEventListener('focus', function() { - fetch('get.php') - .then(response => response.json()) - .then(data => { - usersData = data; - imieSelect.innerHTML = ""; - data.forEach(dane => { - const option = document.createElement('option'); - option.value = dane.id; - option.textContent = dane.imie + " " + dane.nazwisko; - imieSelect.appendChild(option); - }); - }) - .catch(error => console.error('Error fetching data:', error)); - }); + console.log(row); + }); - imieSelect.addEventListener('change', function() { - const selectedId = imieSelect.value; - const selectedPerson = usersData.find(dane => dane.id == selectedId); - if (selectedPerson && selectedPerson.photo) { - photoDisplay.src = 'data:image/jpeg;base64,' + selectedPerson.photo; - } else { - photoDisplay.src = ''; - } - }); + console.log(data); + }) + .catch(error => console.error('Error fetching data:', error)); }); + +fuelType.addEventListener('change', function() { + console.log("Zmiana wybranego paliwa"); + const selectedId = fuelType.value; + + const selectedFuel = usersData.find(dane => dane.nazwa === selectedId); + + cena.textContent = selectedFuel["cena"]; + console.log("mati"); + if (selectedFuel) { + const cena = selectedFuel.cena; + console.log("Cena wybranego paliwa:", cena); + } else { + console.error("Nie znaleziono ceny dla wybranego paliwa"); + } +}); + diff --git a/js/script.js b/js/script.js deleted file mode 100644 index 7225a75..0000000 --- a/js/script.js +++ /dev/null @@ -1,42 +0,0 @@ -const fuelType = document.getElementById('fuel-type'); - -const cena = document.getElementById("cena"); - -let usersData = []; - -document.addEventListener('DOMContentLoaded', function() { - fetch('php/gget.php') - .then(response => response.json()) - .then(data => { - usersData = data; - - data.forEach(row => { - const option = document.createElement('option'); - option.value = row["nazwa"]; - option.textContent = row["nazwa"]; - fuelType.appendChild(option); - - console.log(row); - }); - - console.log(data); - }) - .catch(error => console.error('Error fetching data:', error)); -}); - -fuelType.addEventListener('change', function() { - console.log("Zmiana wybranego paliwa"); - const selectedId = fuelType.value; - - const selectedFuel = usersData.find(dane => dane.nazwa === selectedId); - - cena.textContent = selectedFuel["cena"]; - console.log("mati"); - if (selectedFuel) { - const cena = selectedFuel.cena; - console.log("Cena wybranego paliwa:", cena); - } else { - console.error("Nie znaleziono ceny dla wybranego paliwa"); - } -}); - diff --git a/php/gget.php b/php/gget.php deleted file mode 100644 index 2706976..0000000 --- a/php/gget.php +++ /dev/null @@ -1,15 +0,0 @@ -