JavaScript
  Home arrow JavaScript arrow Page 4 - 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 - Building a Button Control using a simple checkbox


    (Page 4 of 4 )

    In accordance with the concepts that I expressed in the previous section, it’s perfectly feasible to build a Button Control by using different web form tags. With reference to this topic in particular, I already showed you how to include a simple control into a sample web page using different form elements, such as conventional and radio buttons, so in this case I’m going to teach you how to perform the same task, but utilizing a checkbox.

    Having explained that, here’s the corresponding code sample that displays on the browser a basic Yahoo! Button Control by using a common checkbox. Have a look at it, please:

    <!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
    (checkbox)</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="checkbox" 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 you can see, building basic Yahoo! Control Buttons using different elements of a web form is actually a straightforward procedure that can be tackled with minor hassles. In this case, I utilized a basic checkbox to include the control into a sample web document, but the same approach can be implemented with conventional and radio buttons as well.

    Finally, in order to complete the implementation of the practical example, below I included an additional screen shot, which shows the visual appearance of the Control Button created earlier:

     

    All right, having already provided you with a decent number of demonstrative examples of how to build different Yahoo Button Controls using existing structural markup, I believe that you shouldn’t have major problems working with these user interface elements on your own. As with other topics related to professional web development, practice is the best way to go.

    Final thoughts

    In this first article of the series, you hopefully learned how to build basic web controls by using the neat Yahoo Button Control bundled with the Yahoo UI library. As you saw previously, all of the code samples demonstrated how to create these buttons from existing (X)HTML.

    Nevertheless, as I said in the beginning of this article, it’s possible to build these controls with only a few lines of JavaScript code. I'll cover this topic in the next part of the series, so if you’re interested in learning this approach, don’t miss it!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







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