MACROMEDIA COLDFUSION MX 61-CFML Informations techniques Page 28

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 152
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 27
28 Chapter 2: CFML Basics
Using the cfelseif tag to evaluate multiple expressions
To evaluate multiple expressions in a
cfif statement, you can use cfelseif and cfelse tags in
your statement; for example:
<cfif expression 1>
HTML and CFML tags executed if expression 1 is True.
<cfelseif expression 2>
HTML and CFML tags executed if expression 2 is True.
<cfelse>
HTML and CFML tags executed for expression(s) that is False.
</cfif>
The following example shows you how you can evaluate multiple expressions using these tags.
This example uses a form in which users can enter their state to determine their state tax:
<cfoutput>
<cfif form.state IS "MA">
#form.state# State Tax: 8.5%
<cfelseif form.state IS "VA">
#form.state# State Tax: 8.2%
<cfelse>
#form.state# State Tax Unknown
</cfif>
</cfoutput>
The output of this cfif statement is based on the value entered by the user. If the user enters MA
in the state form field, the state tax results returned is 8.5%. If the user enters VA in the state form
field, the state tax results returned is 8.2%. If the user enters any other state in the state form field,
State Tax Unknown is returned.
Processing form data
Virtually all web applications that gather and write information to a database use a form to
accomplish that task. Forms let you collect information from a user (using an order form,
registration form, and so on) and write that information to a database. Like HTML, there are two
independent steps for creating a form in ColdFusion:
1.
Creating the layout for the form itself.
2.
Writing the code to process the submitted information.
Every form that you create in ColdFusion consist of two parts: the form page and the action page.
These two pages work together to process user input. The form page contains the user interface
elements, such as input fields and radio buttons. The action page handles the processing of the
form page data.
Vue de la page 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 151 152

Commentaires sur ces manuels

Pas de commentaire