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

96
Views
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
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!