JavaScript
  Home arrow JavaScript arrow Page 2 - 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 - Building Yahoo! Control buttons using non existing (X)HTML


    (Page 2 of 4 )

    In consonance with the concepts that I deployed in the introduction of this article, it’s also possible to build different types of Button Controls by using only a few lines of JavaScript code. In this way, we avoid working directly with <input> tags. In this case, the only web page element that must be specified is the container in which the control will be placed.

    Indeed, creating a Button Control with JavaScript is a straightforward process, but surely you’ll grasp the logic in implementing this approach much more easily if you have a look at the following hands-on example. It illustrates the creation of a basic button directly from JavaScript. 

    <!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 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 sButton = new YAHOO.widget.Button({

         id: "button1",

        type: "button",

         label: "Sample Button",

        container: "container"

    });

    </script>

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

    </body>

    </html>

    Certainly, the above example isn’t rocket science, right? As you can see, a basic Button Control is built by creating a new instance of the already familiar “YAHOO.widget.Button” class. This class accepts a few input arguments, like the type of button being created, in addition to the ID of the web page container where the control will be placed directly.

    Of course, the final step of this creation process consists of defining the pertinent web page container, which in this case is simply a DIV element. Also, to complement the previous example of how to build a Button Control only with JavaScript, below I included an illustrative screen shot that shows very clearly the visual appearance of the button just created:

    All right, at this stage you learned how to build a basic Button Control by utilizing the assistance of JavaScript. However, I’d like to extend this concept and show you how to create some checkboxes by using the same controls that you learned a few lines before.

    Want to see how this checkbox will be built? Click on the link that appears below and keep reading.

    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