The School for Champions is an educational website that shows you how to achieve your dreams.



Other ColdFusion topics:

Basics

Overview of ColdFusion

ColdFusion Features

Development methods

Setting up ColdFusion

ColdFusion Development Steps

Specific applications

Using Session Variables

Combining the Form and Action Pages

Using Drop-Down Lists

Converting ColdFusion to PDF

Dealing with Dates and Times

Sending a Flash Animation with ColdFusion Email

Changing Data to Telephone Format

Populating a New Database Table from an Old Table

Populating a Matrix Table

Sorting a Table Listing in ColdFusion

Also see:

Weekly Feedback Blog

ColdFusion Survey Results

Flash Development

Website Development

eLearning


SfC Home > ColdFusion >

Explanation of how to combine the ColdFusion markup language form and action pages. Also refer to Allaire, database, client, server, ODBC, functions, if, then, else, Ron Kurtus, School for Champions. Copyright © Restrictions

Combining the ColdFusion Form and Action Pages

by Ron Kurtus (revised 3 July 2001)

The common way to submit forms in ColdFusion is to use a Form page and an Action page. By using some clever programming, you can combine those two pages into one.

Questions you may have include:

This lesson will answer those questions. There is a mini-quiz near the end of the lesson.

Two page method

The common way to submit forms in ColdFusion is to use two pages. First, you have a Form Page, where the user can input information and click a Submit button. The information is then sent to an Action Page, where the material sent from the form can be used to query a database for more information, to insert new information into the database, or perform other tasks.

Combining pages

A clever way to perform both tasks on one page is to use a <CFIF> tag along with the IsDefined function to display what would be on the second page, provided the form has been submitted. The coding would be as follows:

<BODY>
<CFIF IsDefined("form.submit")>
(Note that you could use "form.variable", for any variable sent in your submission.)

(Place material that would be in the Action Page here.)

<CFELSE>

(Place Form Page material here. The name for the Submit button is NAME="submit".)

</CFIF>

What happens

When you first open the page, <CFIF IsDefined("form.submit")> does not apply, so the material after <CFELSE> displays.

After filling in the form and clicking the Submit button, the page refreshes and the <CFIF IsDefined("form.submit")> section is activated, while the <CFELSE> section is hidden.

The IsDefined function checks if the "submit" variable (or other defined variable) has been sent from the form. If it has, then the Action Page material can be displayed and action taken.

Summary

This method can reduce the number of pages you have in an application and can make debugging the code easy to do.

Answers to Readers' Questions


If you are reliable, you are valuable


Resources

The following resources provide information on this subject.

Websites

ColdFusion Resources

Books

Top-rated books on ColdFusion


Mini-quiz to check your understanding

1. What is the usual way of submitting a form?

You form an action page when you submit

You have a form page and an action page.

Submit the form and wait for the results

2. Where do you put the form you will submit?

Near the bottom of the page, after <CFELSE>

Near the top of the page before <CFIF>

At the bottom of the page, after </CFIF>

3. Must you use IsDefined("form.submit")?

Yes, it is the only thing you can use

No, you can substitute another submitted variable for "submit"

No, you can use IsDefined("submit.form")

If you got all three correct, you are on your way to becoming a Champion in ColdFusion Development. If you had problems, you had better look over the material again.


What do you think?

Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. We will try to get back to you as soon as possible.


Share link

Feel free to establish a link from your website to pages in this site.

Or use our form to send this link to yourself or a friend.


Students and researchers

The Web address of this page is
www.school-for-champions.com/coldfusion/onepage.htm.

Please include it as a reference in your report, document, or thesis.


Where can you go from here?

School for Champions

ColdFusion topics

Combining the ColdFusion Form and Action Pages


The School for Champions helps you become the type of person who can be called a Champion.