Home arrow ColdFusion arrow Page 5 - Jump Start To ColdFusion MX
COLDFUSION

Jump Start To ColdFusion MX


Yearning to become a ColdFusion buff? If so, then start with this article -- Clint introduces us to ColdFusion MX using coding examples and great explanations.

Author Info:
By: Clint Tredway
Rating: 4 stars4 stars4 stars4 stars4 stars / 9
September 24, 2002
TABLE OF CONTENTS:
  1. · Jump Start To ColdFusion MX
  2. · What Is ColdFusion?
  3. · Showing The Results Of A Query
  4. · Looping In ColdFusion
  5. · Form Handling
  6. · Conclusion

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

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>

blog comments powered by Disqus
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...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials