HTML5: Create a slider using range

This entry is part 23 of 34 in the series HTML5

The range input type creates a slider interface.

And like the number input type, it can use the min, max, and step attributes.

<input min='0' max='10' step='1' required type='range' id='range_id' name='range'/>

We use a unit step of 1 for the example.

<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>Codecrawl.com: Slider</title>
</head>
<body>
<form>
    <label for='range_id'>Volume Control</label>
    <input min='0' max='10' step='1' required type='range' id='range_id' name='range'/>
    <input type='submit' value='Go'/>
</form>
</body>
</html>

I have tried out the slider in the different browsers.

Here is Chrome implementation.  Slider is supported in Chrome.

chrome_slider

Here is the mozilla implementation.  It is not supported.

firefox_slider

 

 

Here is the Safari implementation.  It is supported.

Safari_slider

 

Here is the IE implementation.  It is supported.

ie_slider

 

jQuery UI & Slider: Vertical range slider

This entry is part 4 of 11 in the series jQuery UI Slider

jQuery UI Slider – Vertical range slider

Change the orientation of the range slider to vertical.

Assign a height value via .height() or by setting the height through CSS, and set the orientation option to “vertical.”

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Slider - Vertical range slider</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#slider-range').slider({
                orientation: 'vertical',
                range: true,
                values: [ 17, 67 ],
                slide: function (event, ui) {
                    $('#amount').val('$' + ui.values[ 0 ] + ' - $' + ui.values[ 1 ]);
                }
            });
            $('#amount').val('$' + $('#slider-range').slider('values', 0) +
                    ' - $' + $('#slider-range').slider('values', 1));
        });
    </script>
</head>
<body>

<p>
    <label for='amount'>Target sales goal (Millions):</label>
    <input type='text' id='amount' style='border:0; color:#f6931f; font-weight:bold;'>
</p>

<div id='slider-range' style='height:250px;'></div>


</body>
</html>
Try The Code Slider Widgets API Doc

jQuery UI & Slider: Range with fixed minimum

This entry is part 6 of 11 in the series jQuery UI Slider

jQuery UI Slider – Range with fixed minimum

Fix the minimum value of the range slider so that the user can only select a maximum.

Set the range option to “min.”

When you move the slider, you are now selecting the maximum value.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Slider - Range with fixed minimum</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#slider-range-min').slider({
                range: 'min',
                value: 37,
                min: 1,
                max: 700,
                slide: function (event, ui) {
                    $('#amount').val('$' + ui.value);
                }
            });
            $('#amount').val('$' + $('#slider-range-min').slider('value'));
        });
    </script>
</head>
<body>

<p>
    <label for='amount'>Maximum price:</label>
    <input type='text' id='amount' style='border:0; color:#f6931f; font-weight:bold;'>
</p>

<div id='slider-range-min'></div>

</body>
</html>
Try The Code Slider Widgets API Doc

jQuery UI & Slider: Range with fixed maximum

This entry is part 3 of 11 in the series jQuery UI Slider

jQuery UI Slider – Range with fixed maximum

Fix the maximum value of the range slider so that the user can only select a minimum.

Set the range option to “max.”  

So now when you are selecting with the slide, you are selecting the minimum value.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Slider - Range with fixed maximum</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#slider-range-max').slider({
                range: 'max',
                min: 1,
                max: 10,
                value: 2,
                slide: function (event, ui) {
                    $('#amount').val(ui.value);
                }
            });
            $('#amount').val($('#slider-range-max').slider('value'));
        });
    </script>
</head>
<body>

<p>
    <label for='amount'>Minimum number of bedrooms:</label>
    <input type='text' id='amount' style='border:0; color:#f6931f; font-weight:bold;'>
</p>

<div id='slider-range-max'></div>

</body>
</html>
Try The Code Slider Widgets API Doc

jQuery UI & Slider: Range

This entry is part 9 of 11 in the series jQuery UI Slider

jQuery UI Slider – Range slider

Set the range option to true to capture a range of values with two drag handles.

The space between the handles is filled with a different background color to indicate those values are selected.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Slider - Range slider</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#slider-range').slider({
                range: true,
                min: 0,
                max: 500,
                values: [ 75, 300 ],
                slide: function (event, ui) {
                    $('#amount').val('$' + ui.values[ 0 ] + ' - $' + ui.values[ 1 ]);
                }
            });
            $('#amount').val('$' + $('#slider-range').slider('values', 0) +
                    ' - $' + $('#slider-range').slider('values', 1));
        });
    </script>
</head>
<body>

<p>
    <label for='amount'>Price range:</label>
    <input type='text' id='amount' style='border:0; color:#f6931f; font-weight:bold;'>
</p>

<div id='slider-range'></div>

</body>
</html>
Try The Code Slider Widgets API Doc