JavaScript
  Home arrow JavaScript arrow Page 3 - A Close Look at the Yahoo Button Control
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 
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

A Close Look at the Yahoo Button Control
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-11-20

    Table of Contents:
  • A Close Look at the Yahoo Button Control
  • Introducing a basic example
  • Using an existing radio button
  • Building a Button Control using a simple checkbox

  • 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


    A Close Look at the Yahoo Button Control - Using an existing radio button


    (Page 3 of 4 )

    As I expressed in the previous section, Yahoo! Button Controls are extremely versatile, since they can be easily built not only by using an <input type=”button”> tag, but by coding other web form elements as well.

    To demonstrate more clearly the previous concept, below I coded a brand new hands-on example, which illustrates how to include a simple Button Control by using an “<input type=”radio”> tag.

    The corresponding 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 simple Yahoo Button with existing input tag
    (radio)</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">

     <input type="radio" id="button1" name="button" value="Sample
    Button" checked>

        <script type="text/javascript">

         var sButton = new YAHOO.widget.Button(

          "button1", // id of source element

     {

      checked: false, // override button attribute

       label: "Click me!"

      }

     );

     </script>

     </body>

     </html> 

    As shown by the previous example, it’s extremely easy to include a basic Button Control utilizing different web form elements. As you can see, I utilized a radio button to build the control in question, whose ID is also passed as an input argument to the pertinent YAHOO.widget.Button class.

    The result of this process is shown by the image below:

     

    So far, so good, right? At this point you hopefully grasped the underlying logic required to include a simple Yahoo! Button control into any web document, since the whole process is indeed very easy to follow. However, I’d like to provide you with yet another example of how to create this type of control. This time we'll use a basic checkbox, in this way completing this practical demonstration of building Button Controls from existing (X)HTML markup.

    To see how this final example will be developed, please go ahead and read the new few lines. 

    More JavaScript Articles
    More By Alejandro Gervasio


       · The popular Yahoo UI DHTML framework comes equipped, among other useful stuff, with...
     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek