document.addEventListener('DOMContentLoaded', function() { const fuelType= document.getElementById('fuel-type'); let usersData = []; // imieSelect.addEventListener('focus', function() { fetch('php/gget.php') .then(response => response.json()) .then(data => { data.forEach(row => { const option = document.createElement('option'); option.value = row["nazwa"]; //option.textContent = dane.imie + " " + dane.nazwisko; fuelType.appendChild(option); option.textContent = row["nazwa"]; console.log (row) }); /* 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 = ''; } }); */ });