Design Usability
  Home arrow Design Usability arrow Page 5 - Using HTML_QuickForm To Manage Web Forms, ...
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? 
DESIGN USABILITY

Using HTML_QuickForm To Manage Web Forms, Part 1
By: Harish Kamath
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 55
    2004-12-22

    Table of Contents:
  • Using HTML_QuickForm To Manage Web Forms, Part 1
  • Installing The HTML_QuickForm Package
  • My First HTML_QuickForm
  • FORM Elements
  • Adding Standard HMTL FORM Elements
  • Defining FORM Controls, Submitting Data
  • Grouping
  • "Checkbox" and "Radio" Elements
  • Drop Down Control and Hidden Element
  • Implementing Form Validations
  • Password Field Validation
  • Processing Data With HTML_QuickForm
  • Conclusion

  • 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 HTML_QuickForm To Manage Web Forms, Part 1 - Adding Standard HMTL FORM Elements


    (Page 5 of 13 )

    Note that the number of input parameters passed to the addElement() method varies with the nature of the element added to the Web form. While it is sufficient to pass only two values for the "html" and "header" elements, it is a different ball game when it comes to adding standard HTML <FORM> elements. Take a look at the following code snippet:

    <?php

    // snip

    $obj_registration_form->addElement('text', 'txtFullName', 'Full Name:', array('size' => 40, 'maxlength' => 50));
    $obj_registration_form->addElement('textarea', 'txtAddress', 'Address:', array('rows' => 3, 'cols' => 30));
    $obj_registration_form->addElement('select', 'txtCountry', 'Country:', array ("" => "Select Country", "USA" => "United States","UK" => "United Kingdom","IND" => "India", "Other" => "Other"));
    $obj_registration_form->addElement('text', 'txtEmailAddress', 'e-mail Address:', array( 'size' => 40, 'maxlength' => 255));
    $obj_registration_form->addElement('radio', 'txtGender', 'Select Gender:', 'Male', 'M');
    $obj_registration_form->addElement('radio', 'txtGender', '', 'Female', 'F');

    // snip

    ?>

    First, I have added a "text" input control. This time, you'll notice that I have passed four parameters - first, the keyword "text" indicates that I want to render a "text" <INPUT> element, the second parameter represents the "name" of the text field, the third is the the "label" to displayed along side the control and finally, an array consisting of key-value pairs. Take a close look at this array and you will notice I have assigned values for some commonly used attributes of the <INPUT> HTML element.

    Things are similar for a <TEXTAREA> control. The only major change is the use of the keyword "textarea" for obvious reasons. You will also note that the array, i.e. the fourth optional parameter of the addElement() method, has been updated to define the size of the text area.

    Next, I want to add a <SELECT> control. As you might have guessed, I pass the "select" keyword along with the control name and text for display label. But what about the options to be displayed in the drop down?  No sweat - all I need to do is define an array with set of key-value pairs, where the value is the text displayed in the browser and the key represents the value submitted to the server for the selected <OPTION>.

    This is followed by the "radio" <INPUT> control. Once again, it's the "radio" keyword that does the trick. Of course, I've added another "radio" button with the same "name" because I want the user to select only one value - this is akin to the definition of two <INPUT> radio buttons with the same "name" in good ol’ HTML.

    More Design Usability Articles
    More By Harish Kamath


       · When first time i saw this article i thought that it will solve all my problems that...
       · Then install the pear common package.
       · Great article! Where and how does the $ary_artist_info array get created in this...
     

    DESIGN USABILITY ARTICLES

    - Create Great JavaScript and CSS Menus Simply
    - Design Principles that Shape a Web Site
    - Creating Aqua Style Images
    - Easy as A,B,C – dynamic A to Z indexes
    - EasyChart: a Usability Teaching Tool to Demo...
    - Building Friendly Pop-up Windows
    - Back to School: Design Usability
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - More Website Knick Knack
    - Browsers as Test Platforms
    - Website Knick Knack
    - Dynamic Page Elements-Cloak and Dagger Web D...
    - Accessibility and Dreamweaver MX 2004







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