Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptscript.aculo.us Sliders sliderValue Option

script.aculo.us Sliders sliderValue Option

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:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments