Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
Javascript-added datalist and text input not showing options

I was trying to make a search bar for a navigation menu with data lists, and I used JavaScript to do it automatically on every page. However, it is not working, how do I solve this?

Definition of the text input

let searchBar = document.createElement("input");
searchBar.type = "text";
searchBar.list = "search-results";
searchBar.id = "search-bar";
searchBar.name = "search-bar";

The datalist

let searchResults = document.createElement("datalist");
searchResults.id = "search-results";

And the options

const searchPagesDisplayNames = ["Home","Numbers","WIPs","Interpreters","Noise","What's the difference?","Star Calculator", "Tsevhu","Bee Swarm Ideas"];
const searchLinks = []; //Censored (not a mistake)
for (let i = 0; i < searchPagesDisplayNames.length; i++) {
  let option = document.createElement("option");
  option.value = searchPagesDisplayNames[i];
  searchResults.appendChild(option);
}

The search bar and the data list are being added to the same parent element later on. I've looked through the code and found nothing wrong. Please help

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda