ColdFusion
  Home arrow ColdFusion arrow Page 5 - Jump Start To ColdFusion MX
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? 
COLDFUSION

Jump Start To ColdFusion MX
By: Clint Tredway
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2002-09-24

    Table of Contents:
  • Jump Start To ColdFusion MX
  • What Is ColdFusion?
  • Showing The Results Of A Query
  • Looping In ColdFusion
  • Form Handling
  • 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


    Jump Start To ColdFusion MX - Form Handling


    (Page 5 of 6 )

    When a form is submitted, ColdFusion places all of the form variables in the 'form' scope. If I had a form field named 'username', I would access this value like this:

    #form.username#

    For the record, you do not have to use the scope to gain access to this variable, although using the scope is a good programming practice. ASP and PHP developers will be familiar with this content for the Request and $_POST collections respectively.

    ColdFusion also places all form values submitted into a structure. This is very helpful when building dynamic forms. Lets go over a simple code example:

    Place this in a page called myname.cfm:

    <form action="test.cfm" method="post">
    Enter Your Name:<input type="text" name="myname" size="30"><br>
    <input type="submit" name="go" value="Submit Name">
    </form>


    Here is test.cfm:

    <cfif IsDefined('form.myname')>
    Hello <cfoutput>#form.myname#</cfoutput>
    <cfelse>
    Please enter your name.
    </cfif>


    When the form is submitted the if block will see that the variable 'form.myname' is present and it will output 'Hello Your Name Here'. Pretty simple isn't it?

    Conditional Statements
    Let’s now look at using conditional if statements. I just used if and an else in the previous coding example. Using if statements in ColdFusion is very easy. The tag syntax is as follows:

    <cfif expression goes here>
    code to execute if the if statement is true
    </cfif>


    The if statements can get much more complicated than the example I just showed you, but you get the idea. You can also have else's and elseif's in there as well. Here's a short example:

    <cfif IsDefined('form.myname')>
    Hello <cfoutput>#form.myname#</cfoutput>
    <cfelseif Not IsDefined('form.myname')>
    Please enter your name.
    <cfelse>
    Something else goes here.
    </cfif>

    More ColdFusion Articles
    More By Clint Tredway


     

    COLDFUSION ARTICLES

    - Adobe ColdFusion Just Got More RAD
    - How to Access a SQL Anywhere Database with C...
    - CFXML: Probing XMLDOM in ColdFusion
    - Creating a Web Service with ColdFusion: the ...
    - CFAjax: What it is and How to Use it
    - Querying SQL 2000 Server from ColdFusion
    - Introduction to ColdFusion Markup Language, ...
    - Introduction to ColdFusion Markup Language
    - Databases and Dreamweaver MX 2004, concluded
    - Databases and Dreamweaver MX 2004
    - Welcome to Coldfusion MX 6.1, concluded
    - Welcome to Coldfusion MX 6.1
    - What You Must Know About ColdFusion Flow-Con...
    - What You Must Know About Operators in ColdFu...
    - Everything You Must Know About ColdFusion Va...







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