Open In App

script.aculo.us Sliders Disabled Option

Improve
Improve
Like Article
Like
Save
Share
Report

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 disabled option is used to define whether the given slider is disabled or not. A disabled slider would be locked and hence not be able to be moved by the user. This option accepts a boolean value, where a value of true specifies the slider to be disabled and false specifies that it is not disabled.

Syntax:

{ disabled: boolean }

Values:

  • boolean: This is a boolean value that specifies whether the slider is disabled or not.

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;">
        GeeksforGeeks
    </h1>
  
    <h2>Sliders disabled</h2>
  
    <p>
        The slider can be disabled or enabled 
        using the "disabled" 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),
  
            sliderValue: 5,
  
            // This will disable the Slider
            // and it will be locked
            disabled: true
        });
  
        new Control.Slider('handle2-hor',
            'track2-hor', {
            range: $R(1, 10),
  
            sliderValue: 5,
  
            // This will enable the Slider
            // to be used
            disabled: false
        });
    </script>
</body>
  
</html>


Output:



Last Updated : 20 Nov, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads