Friday, December 12, 2025
HomeLanguagesJavascriptscript.aculo.us Sliders Axis Option

script.aculo.us Sliders Axis 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 Axis option is used to define the axis or direction that the slider is supposed to move in. This option accepts a string value that can be set to ‘horizontal’ or ‘vertical’ depending on the direction required.

Syntax:

{ axis : horizontal | vertical }

Values: This option has two values as mentioned above and described below:

  • horizontal: This would define the direction of the slider to be horizontal. It is the default value.
  • vertical: This would define the direction of the slider to be vertical.

Example 1:

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 axis</h2>
  
    <p>
        The slider is on the 
        horizontal axis.
    </p>
  
    <div class="pad">
        <div id="track-hor" class="track">
            <div id="handle-hor" class="handle">
            </div>
        </div>
    </div>
  
    <p>Current Slider Value:
        <span id="out">0</span>
    </p>
  
    <script type="text/javascript">
        new Control.Slider('handle-hor',
            'track-hor', {
            range: $R(1, 100),
  
            // Set the axis of the slider
            // to be horizontal 
            axis: 'horizontal',
  
            onSlide: (val) => {
                document.querySelector("#out")
                    .textContent = val;
            }
        });
    </script>
</body>
  
</html>


Output:

Example 2:

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: 5px;
            background-color: gray;
            height: 150px;
            position: relative;
        }
  
        .track .handle {
            width: 20px;
            height: 10px;
            background-color: green;
            cursor: move;
            position: absolute;
            left: -8px;
        }
  
        .pad {
            padding: 25px;
        }
    </style>
</head>
  
<body>
    <h1 style="color: green;">
        neveropen
    </h1>
  
    <h2>Sliders axis</h2>
  
    <p>The slider is on the vertical axis.</p>
  
    <div class="pad">
        <div id="track-vert" class="track">
            <div id="handle-vert" class="handle">
            </div>
        </div>
    </div>
  
    <p>Current Slider Value:
        <span id="out">0</span>
    </p>
  
  
    <script type="text/javascript">
  
        new Control.Slider('handle-vert',
            'track-vert', {
            range: $R(1, 100),
  
            // Set the axis of the slider
            // to be vertical 
            axis: 'vertical',
  
            onSlide: (val) => {
                document.querySelector("#out")
                    .textContent = val;
            }
        });
    </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

Dominic
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12028 POSTS0 COMMENTS
Shaida Kate Naidoo
6946 POSTS0 COMMENTS
Ted Musemwa
7198 POSTS0 COMMENTS
Thapelo Manthata
6892 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS