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

256
Views
How to make off-centered range input?

I have a range input, by default, its center is 50 points of 100. I need 20 points in center, but leave max of 100. How to do it? (image example)

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

0

This is entirely up to you. The actual input range wll be linear but how your code interprets the value it gets back is in your control.

So set the range on the input to min 0 and max 100. But when you get the value in Javascript you interpret it as you wish.

The simplest curve you can fit to the values (x1, y1), (x2, y2), (x3, y3) is a parabola: y1 = ax1x1 + b*x1 + c; and so on

Solving these three simultaneous equations for your points (0, 0), (50, 20), (100, 100) we get: a=3/250; b=-0.2; c=0;

function getValue(v) {
  document.querySelector('#value').innerHTML = 3 / 250 * v * v - 0.2 * v;
}
getValue(document.querySelector('input').value);
<input type="range" min=0 max=100 onchange="getValue(this.value);">
<div>The calculated value is <span id="value"></span></div>

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!