#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13

    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. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    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

    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
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    254
    Rep Power
    13
    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.
    Thank you for any help.

IMN logo majestic logo threadwatch logo seochat tools logo