JavaScript
  Home arrow JavaScript arrow Page 3 - Building Controls with JavaScript and the ...
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  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
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? 
JAVASCRIPT

Building Controls with JavaScript and the Yahoo Button Control
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-11-27

    Table of Contents:
  • Building Controls with JavaScript and the Yahoo Button Control
  • Building Yahoo! Control buttons using non existing (X)HTML
  • Using JavaScript and Yahoo! Button Controls to work with checkboxes
  • Using the Yahoo! Button Control to build some basic radio buttons

  • 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


    Building Controls with JavaScript and the Yahoo Button Control - Using JavaScript and Yahoo! Button Controls to work with checkboxes


    (Page 3 of 4 )

    As you’ll probably recall from the previous section, it’s extremely easy to use the handy Yahoo! Button Control to create professional-looking checkboxes, which naturally can be included into any web form.

    Undoubtedly, the procedure for building these visual appealing checkboxes will be better understood if you take some time to study the following practical example:

    <!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 "checkbox" Yahoo Button using no existing
    HTML</title>

    <!-- Include core + Skin CSS files-->

    <link rel="stylesheet" type="text/css"
    href="build/button/assets/skins/sam/button.css">

    <!-- This file is optional: Menu Stylesheet (required for
    creating buttons of type "menu" and "split") -->

    <link rel="stylesheet" type="text/css"
    href="build/menu/assets/skins/sam/menu.css">

    <!-- Include dependencies -->

    <script type="text/javascript" src="build/yahoo-dom-event/yahoo-
    dom-event.js"></script>

    <script type="text/javascript" src="build/element/element-beta-
    min.js"></script>

    <!-- This file is optional: Menu and Container Core (required
    for creating buttons of type "menu" and "split") -->

    <script type="text/javascript"
    src="build/container/container_core-min.js"></script>

    <script type="text/javascript" src="build/menu/menu-
    min.js"></script>

    <!-- Source file -->

    <script type="text/javascript" src="build/button/button-beta-
    min.js"></script>

    </head>

      <body class="yui-skin-sam">

       <script type="text/javascript">

        var sCheckButton1 = new YAHOO.widget.Button({

       type: "checkbox",

        label: "CheckBox1",

       id: "checkbutton1",

        name: "checkboxfield1",

        value: "1",

       container: "container",

        checked: true });

     var sCheckButton2 = new YAHOO.widget.Button({

      type: "checkbox",

       label: "CheckBox2",

        id: "checkbutton2",

        name: "checkboxfield2",

         value: "2",

       container: "container",

        checked: true });

     var sCheckButton3 = new YAHOO.widget.Button({

      type: "checkbox",

       label: "CheckBox3",

        id: "checkbutton3",

        name: "checkboxfield3",

        value: "3",

       container: "container",

        checked: true });

    </script>

    <div id="container"></div>

    </body>

    </html>

    As illustrated above, building a few basic checkboxes using the Yahoo! Button Control is indeed a straightforward process that can be performed with minor problems. As you can see, in this case I created three new instances of the “YAHOO.widget.Button class, and then I specified a value of “checkbox” for its respective “type” incoming argument.

    Finally, I coded a simple DIV, identified as “container,” which is used by the aforementioned class instances to place the respective checkboxes in the sample web document. Also, to complement the previous code sample, below I included another illustrative image, which shows how the checkboxes in question are displayed by the browser:

    Even though this explanation may sound a bit obvious, if you copy the source code corresponding to the prior example, and test it on your own computer, you’ll see that all the Button Controls behave exactly like real (X)HTML checkboxes, which means that they can be checked/unchecked individually.

    All right, at this moment I think that you’ll have a more appropriate idea of how to utilize the remarkable functionality offered by the Yahoo! Button Control to build some basic web form elements, like simple buttons and checkboxes.

    However, this tutorial would be rather incomplete if I don’t show you another hands-on example where these controls are used to build some eye-catching radio buttons. Sounds really interesting, right?

    Thus, if you want to learn how this will be done, jump ahead and read the final section of this article. It’s just one click away.

    More JavaScript Articles
    More By Alejandro Gervasio


       · In the last article of the series, you saw for yourself how easy is to build a...
       · Thanks so much for this articles.
       · Thank you for the compliments on my articles on Yahoo! Button controls and I hope...
     

    JAVASCRIPT ARTICLES

    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...







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