spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / hform current pageTo page 2
[next]

Web Project Manager
Aquent
US-PA-Collegeville

Justtechjobs.com Post A Job | Post A Resume
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

The HTML Form Element

Form elements are probably one of the most important aspects of HTML that we come across when browsing the web. It allows communication between a client (more commonly known as the web browser) and a web server. Many of us have probably used forms at one time or another, such as when purchasing a book over the Internet, filling out product surveys or for web based email..

In this article we'll take a look at some of the more common attributes used for form elements and why it's necessary to use them. Next, we'll look at some of the children elements for Form elements which are known as controls. From there, we'll take a look at some common form submission issues.

What is the Form Element?

It's the section of the HTML document that may contain normal content, some markup, controls (or html element such as checkboxes, radio buttons, text fields, etc.) and labels on those controls.

A typical Form element may contain a variety of controls, and one or many controls on a given form.

A form element must have a start tag and an end tag, meaning all the controls will be between the form's open and close tags.

<form action=""> .... rest of the controls will go here </form>

Note: All of the controls that make up a full functional form can also appear outside of the form as well, but they function differently in either place.

Some Important Attributes

action : There are a number of attributes that are used in form elements, however a form element must always contain an action attribute. The action attribute points to a form processing application or mechanism (mostly a server side application). Action attribute values should be in the following format:

protocol : resource
such as
http://myformprocessing.jsp

A list of some valid protocols that can be used in action attributes are as follows:

  ftp                     File Transfer protocol
  http                    Hypertext Transfer Protocol
  gopher                  The Gopher protocol
  mailto                  Electronic mail address
  news                    USENET news
  nntp                    USENET news using NNTP access
  telnet                  Reference to interactive sessions
  wais                    Wide Area Information Servers
  file                    Host-specific file names
  prospero                Prospero Directory Service
method : By default, if no method attribute is specified, GET method is used. You can choose between GET and POST methods. When using GET method (uses enctype="application/x-www-form-urlencoded"), the browser application will append the form data to the url in the form control's (element) name=value format separating them with an & sign. Post is more of a discreet type, in that form data is created explicitly using the enctype attributes value [View a list of MIME Types].
enctype : Default value for enctype attribute is:

application/x-www-form-urlencoded

in the above enctype settings the form data is restricted to ASCII codes.

Another important enctype is:

multipart/form-data

The application/x-www-form-urlencoded is not suitable to send large quantities of data that may contain binary data or non-ascii characters. In situations where you are uploading files and/or other binary data, multipart/form-data content type should be used. Another important enctype that you might have used or will use in the future is text/plain. This content type value is used when you're submitting your form data using the mailto: protocol in the action attributes value. You might find that some people do not approve this usage, (but in my opinion, its perfectly valid enctype that can be used with a perfectly valid mailto protocol).

The only problem you that might encounter with the mailto protocol is that its implementation within the browser community is not as universal as one might think, hence problems may be experienced in different browsers when using the combination of action="mailto:...." and enctype="text/plain" (works as intended in IE6 and NS6+).

One more important configuration issue is that you must have an email client installed on your local system to use the above. i.e. MS Outlook or Netscape mail client.

Click here to see a detailed list of Form Element attributes

home / programming / javascript / hform current pageTo page 2
[next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Fixing MySQL Replication · Firewall Guide: First Steps to Securing the Enterprise · VoxOx Tames the Tumultuous Communications Tangle

Created: June 2, 2003
Revised: October 16, 2003

URL: http://webreference.com/programming/javascript/hform