Blog

Scopri le ultime novità su prodotti, eventi e promozioni.

Seguici su Facebook!

Per restare sempre aggiornato seguici sui nostri canali social.
Ti attendono tantissime novità sui prodotti Rossato e non solo! 

document.addEventListener("DOMContentLoaded", () => { // Carica i dati dal file JSON fetch('/path/to/cap_data.json') .then(response => response.json()) .then(data => { const provinceDropdown = document.getElementById('dropdown-province'); const cityDropdown = document.getElementById('dropdown-city'); const capDropdown = document.getElementById('dropdown-cap'); // Popola il dropdown delle province const provinces = [...new Set(data.map(item => item.Provincia))]; provinces.forEach(province => { const option = document.createElement('option'); option.value = province; option.textContent = province; provinceDropdown.appendChild(option); }); // Event listener per il dropdown province provinceDropdown.addEventListener('change', (e) => { const selectedProvince = e.target.value; cityDropdown.innerHTML = ''; capDropdown.innerHTML = ''; capDropdown.disabled = true; if (selectedProvince) { const cities = [...new Set(data .filter(item => item.Provincia === selectedProvince) .map(item => item.Città))]; cities.forEach(city => { const option = document.createElement('option'); option.value = city; option.textContent = city; cityDropdown.appendChild(option); }); cityDropdown.disabled = false; } else { cityDropdown.disabled = true; } }); // Event listener per il dropdown città cityDropdown.addEventListener('change', (e) => { const selectedCity = e.target.value; capDropdown.innerHTML = ''; if (selectedCity) { const caps = data .filter(item => item.Città === selectedCity) .map(item => item.CAP); caps.forEach(cap => { const option = document.createElement('option'); option.value = cap; option.textContent = cap; capDropdown.appendChild(option); }); capDropdown.disabled = false; } else { capDropdown.disabled = true; } }); }); });