DHTML
  Home arrow DHTML arrow Page 2 - Using Sliders with the Scriptaculous Frame...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DHTML

Using Sliders with the Scriptaculous Framework
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-04-24

    Table of Contents:
  • Using Sliders with the Scriptaculous Framework
  • Coding a basic vertical slider with the Scriptaculous framework
  • Coding a horizontal DHTML slider
  • Using additional parameters with the Control.Slider object

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Sliders with the Scriptaculous Framework - Coding a basic vertical slider with the Scriptaculous framework


    (Page 2 of 4 )

    As I explained in the beginning of this tutorial, including a DHTML slider within a given web document can be accomplished with minor efforts. The procedure is limited to using the "Control.Slider" object that obviously comes bundled with the Scriptaculous framework.

    The first example that I’m going to show you covers the implementation of a basic vertical slider, whose look and feel is depicted in the screen shot below: 

    As you can see, the DHTML slider shown above is quite appealing. It features two primary elements, its sliding track and the respective handle. However, now that you have seen how this control looks, let me show you the corresponding (X)HTML file that displays this element in a conventional web page.

    The respective code sample is as follows: 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-
    8859-1" />
    <title>Example of vertical slider</title>
    <script language="javascript" src="js/prototype.js"></script>
    <script language="javascript" src="js/scriptaculous.js"></script>
    <script language="javascript">
    function initializeSlider(){
       new Control.Slider('handle','slider',
    {axis:'vertical',minimum:0,maximum:200,alignY:0});
    }
    Event.observe(window,'load',initializeSlider,false);
    </script>
    <style type="text/css">
    h1{
       font: bold 12px Verdana, Arial, Helvetica, sans-serif;
       color: #000;
    }

    #slider{
       width: 6px;
       height: 200px;
       background: #ccc;
    }

    #handle{
       width: 12px;
       height: 8px;
       background: #f90;
    }
    </style>
    </head>
    <body>
     
    <h1>Example of vertical slider</h1>
     
    <div id="slider">
       
    <div id="handle"></div>
     
    </div>
    </body>
    </html>

    In this case, I used the functionality provided by the Prototype library, in conjunction with the Scriptaculous JavaScript package, to include the vertical slider that you saw previously into a sample web document.

    As I said before, the inclusion of this DHTML control is performed by using the "Control.Slider" object that comes integrated with this software. The object accepts some intuitive parameters, such as the ID's values that correspond to the handle and the sliding track of the slider respectively (in this case I used two DIVs to contain these elements). It also specifies its alignment via its "axis" argument.

    You can see that I specified a couple of additional parameters for the slider, including its minimum and maximum values, and the vertical offset of its handle, via the "alignY" argument. Quite simple, right?

    Of course, it should be noticed that it’s possible to specify even more input arguments for a concrete slider, but these extra features will be covered progressively in subsequent hands-on examples.

    All right, at this point you have seen how to include a simple vertical slider into a given web document via the powerful "Control.Slider" object that comes packaged with the Scriptaculous animation framework. Therefore I believe that it’s a good time to go forward and explore other controls integrated with this package, in this case to see how to code a horizontal slider.

    As you might have guessed, the process will be closely similar to the one just described a few lines above, but it will be discussed in the following section. So, click on the link below and keep reading.

    More DHTML Articles
    More By Alejandro Gervasio


       · If you're interested on including new components into your web-based user...
     

    DHTML ARTICLES

    - Text-Justify, Volume, and Other Style Sheet ...
    - Ruby-Position, Size, and Other Style Sheet P...
    - Padding, Pages, and More Style Sheet Propert...
    - Marks, Orphans, and More Style Sheet Propert...
    - Layouts, Margins, and Other Style Sheet Prop...
    - Floats, Fonts, and Other Style Sheet Propert...
    - Color, Filters, and Other Style Sheet Proper...
    - Borders and More with Style Sheets
    - Learning Style Sheet Properties
    - Style Sheet Property Reference
    - Completing a Noisy Image Application
    - An Object-Based Approach to Building Noisy I...
    - A Basic Method for Building Noisy Images
    - Adding More Features to Sliders with the Scr...
    - Using Sliders with the Scriptaculous Framewo...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT