Pregunta rápida, luchando con la implementación de Selectric en nuestra función Autocompletar...
¿Puede alguien darme un consejo rápido sobre cómo se ve la sintaxis correcta?
var select = document.getElementById("selectAddress"), street = document.getElementById("streetInput"), city = document.getElementById("cityInput"), postal = document.getElementById("postalInput"), state = document.getElementById("stateInput"); country = document.getElementById("countryInput") language = document.getElementById("language") apiForm = document.getElementById("apiform") console.log(apiForm) var mapping = { "1": { 'sampleStreet': "Heilsbronner Strasse 4", 'sampleCity': "Neuendettelsau", 'samplePostal': "91564", 'sampleState': "Bayern", 'sampleCountry': "de" }, "2": { 'sampleStreet': "1600 Pennsylvania Avenue", 'sampleCity': "Washington", 'samplePostal': "20500", 'sampleState': "Washington DC", 'sampleCountry': "us" }, "3": { 'sampleStreet': "Champ de Mars 5 Av. Anatole", 'sampleCity': "Paris", 'samplePostal': "75007", 'sampleState': "Paris", 'sampleCountry': "fr" }, "4": { 'sampleStreet': "1 Queen's Rd W", 'sampleCity': "Hong Kong", 'samplePostal': "Neuendettelsau", 'sampleState': "Hong Kong", 'sampleCountry': "hk" }, }; select.addEventListener("change", function () { var selectedMapping = mapping[select.value]; if (selectedMapping) { street.value = selectedMapping.sampleStreet; city.value = selectedMapping.sampleCity; postal.value = selectedMapping.samplePostal; state.value = selectedMapping.sampleState; $(country.value(selectedMapping.sampleCountry)).selectric("refresh"); } else { street.value = city.value = postal.value = state.value = postal.value = null $(country.val(null).selectric("refresh")); } });