Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
February 14th, 2012, 07:27 PM
 irm_lexx
Contributing User

Join Date: Mar 2002
Posts: 254
Time spent in forums: 2 Days 20 h 14 m 5 sec
Reputation Power: 12
Implementing a range slider

Hi,

I was wondering if anyone knows the logic of implementing a range slider.

So the parameters are:
minimum value
maximum value
current value

I guess what I'm confused about is if I want to keep the display size the same for all values then how do I figure out the current display value of the current value?
__________________
Thank you for any help.

#2
February 14th, 2012, 08:01 PM
 E-Oreo
Lost in code

Join Date: Dec 2004
Posts: 8,233
Time spent in forums: 2 Months 2 Days 20 h 11 m 10 sec
Reputation Power: 7169
Using basic algebra; the display value is directly related to the current value:

(current value - min value) / (max value - min value) == (current display value - min display value) / (max display value - min display value)

Normally min display value is 0 and max display value is the width of your slider; thus current display value is the left-offset of the position of the slider.
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
 Originally Posted by Spad Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

#3
February 15th, 2012, 09:28 PM
 irm_lexx
Contributing User

Join Date: Mar 2002
Posts: 254
Time spent in forums: 2 Days 20 h 14 m 5 sec
Reputation Power: 12
Quote:
 Originally Posted by E-Oreo Using basic algebra; the display value is directly related to the current value: (current value - min value) / (max value - min value) == (current display value - min display value) / (max display value - min display value) Normally min display value is 0 and max display value is the width of your slider; thus current display value is the left-offset of the position of the slider.

Thanks that seems to work.

 Viewing: Dev Shed Forums > Other > Dev Shed Lounge > Implementing a range slider