The script.aculo.us library is a cross-browser library that aims to improving the user interface of a website. The Slider controls are thin tracks that allow the user to input values. It is done by defining a range of values that can be selected by the user by dragging the handle to the appropriate value.
The Sliders sliderValue option is used to define the initial value that the slider handle would be set. This is only followed when the given value is within the range of the values that the slider is allowed to represent.
Syntax:
{ sliderValue: value }
Values:
- value: This is a number that will be the initial value of the slider. The default value is 0.
Example
HTML
<!DOCTYPE html> < html > < head > <!-- Include the required scripts --> < script type = "text/javascript" src = "prototype.js" > </ script > < script type = "text/javascript" src = "scriptaculous.js?load = slider" > </ script > <!-- Style the Sliders so that they are properly visible --> < style type = "text/css" > .track { width: 250px; background-color: gray; height: 5px; position: relative; } .track .handle { width: 20px; height: 10px; background-color: green; cursor: move; position: absolute; top: -2px; } .pad { padding: 25px; } </ style > </ head > < body > < h1 style = "color: green;" > neveropen </ h1 > < h2 >Sliders sliderValue</ h2 > < p > The slider has been initially set to the values mentioned in the sliderValue option </ p > < div class = "pad" > < div id = "track-hor" class = "track" > < div id = "handle-hor" class = "handle" > </ div > </ div > </ div > < div class = "pad" > < div id = "track2-hor" class = "track" > < div id = "handle2-hor" class = "handle" > </ div > </ div > </ div > < script type = "text/javascript" > new Control.Slider('handle-hor', 'track-hor', { range: $R(1, 10), // Set the initial value // of the slider sliderValue: 7.75, }); new Control.Slider('handle2-hor', 'track2-hor', { range: $R(1, 10), // Set the initial value // of the slider sliderValue: 2, }); </ script > </ body > </ html > |
Output: