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

187
Views
How to limit display size of a datalist?

I have a datalist with a bunch of numbers and would like to limit the display size of the menu to 5 options, but as I understand this can't be done with html/css, so what are my options?

// Generate an array from 1-144 in increments of 0.5
var length = [];
var list = document.getElementById('lengthDatalist');

for (let i = 1; i <= 144; i+= 0.5) {
  length.push(i.toFixed(1));
}; 

//For each item in array length, create an option in datalist
length.forEach(function(item){
   var option = document.createElement('option');
   option.value = item;
   list.appendChild(option);
});
<input name= "lengthInput" id="lengthInputID" list="lengthDatalist" />
     <datalist id="lengthDatalist"></datalist>

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!