0

I've got a input range which is teasing be a bit. The value starts at 0 but it jumps right to 40000 one way and -10000 the other way. I want it to jump 50000 - step indicator is set to 50000. I guess it's because the min and max number is not divided by 50000.

Example:

<input name="example" type="range" max="2240000" min="-160000" value="0" step="50000">

(The numbers is drawn from a database)

But basicly I want - in this example - the inputfield to round min to -150000 and max to 2200000

Thanks in advance!

2

2 Answers 2

2

If min and max is drawn from database, you need to change it. Example in php:

<?php 

$min = -160000;
$max = 2240000;
$step = 50000;

echo $min = intdiv($min , $step) * $step;       
echo '<br>';
echo $max = intdiv($max, $step) * $step;    
?>

Output:

-150000
2200000
0
0

I'm not sure I understand the question, but if you want 2200000 as max and -150000 as min why don't you put them in the input?

<input name="example" type="range" max="2200000" min="-150000" value="0" step="50000">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.