Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

56
Views
Agregue opciones de lista de datos HTML desde la propiedad de un objeto en JS
<datalist id="city-list"> </datalist> <script> let list = document.getElementById('city-list'); const cities = [ { id: 0, city: "Buenos Aires", country: "Argentina", codeIATA: "AEP", aeroName: "Aeroparque Internacional Jorge Newbery", coordX: -58.370277777778, coordY: -34.575, }, { id: 1, city: "Bariloche", country: "Argentina", codeIATA: "BRC", aeroName: "Aeropuerto Internacional Teniente Luis Candelaria", coordX: -71.166666666667, coordY: -41.133333333333, }, { id: 2, city: "Córdoba", country: "Argentina", codeIATA: "COR", aeroName: "Aeropuerto Internacional Ingeniero Ambrosio Taravella", coordX: -64.216666666667, coordY: -31.316666666667, }, ]; cities.forEach(function(city){ let option = document.createElement('option'); option.value = city; list.appendChild(option); }); </script>

¿Cómo agregar como opción al datalist solo la propiedad (en este caso CIUDAD) de cada objeto? Parece que solo estoy agregando el objeto completo, quiero seleccionar solo la propiedad CITY de ellos.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En su función forEach, hace referencia a la ciudad, que es el objeto completo, intente hacer lo siguiente:

 cities.forEach(function(city){ let option = document.createElement('option'); option.value = city.city; //reference the city part of your object list.appendChild(option); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!