home Links Articles Books Past Meetings Photos SiteMap
The MDCFUG is sponsored by TeraTech. Visit us at www.TeraTech.com

Please send
comments/questions to

michael@
teratech.com

 

ColdFusion Class Notes for 11/1/1999

 

Review of Homework from Week 1

 

1.      Hidden type input fields in a form.  This input type is used as another way to prevent system errors from being seen by the user and is an alternative to using the “isdefined” function on the action page (see number 2).  The fields are declared within a form statement on the input page as shown below:

 

                        <FORM action=”actionpagename” method=”post”>

                       

·        Required – displays standard error message if the variable is not defined

<INPUT type=“hidden” name=”varname_required”>

·        Text – displays standard error message if entered data is not text

<INPUT type=“hidden” name=”varname_text”>

·        Number – displays standard error message if entered data is not a number

<INPUT type=“hidden” name=”varname_number”>

·        Date – displays standard error message if entered data is not a date

<INPUT type=“hidden” name=”varname_date”>

 

                        </FORM>

     

2.      Isdefined(), istext(), and isdate() functions.  These functions are useful for determining whether or not a value has been defined in an INPUT page.  The function is used on the action page and can also be used prevent users from seeing system errors if they accidentally get to the page without first entering the data on the INPUT page.  Examples are given below:

 

                        <CFIF not isdefined("varname")>

<CFSET “varname”="defaultvalue">

The varname is not defined and has been set to defaultvalue. 

To change it, please enter a new value.

                       </CFIF>

 

                        <CFIF not istext("varname")>

<CFSET “varname”="defaultvalue">

The varname is not text and has been set to defaultvalue. 

To change it, please enter a new value.                   

                        </CFIF>

 

                        <CFIF not isdate("varname")>

<CFSET “varname”="defaultvalue">

The varname is not a date and has been set to defaultvalue. 

To change it, please enter a new value.

                        </CFIF>

 

New Information for Week 2

 

1.   <CFPARAM> tag.  This tag can be used instead of the “<CFIF> not isdefined()> <CFSET> </CFIF>” statements given above.  For example, the following is equivalent to the first example in number 2 above:

 

            <CFPARAM name=”varname” default=”defaultvalue”> 

 

 

2.   <CFLOOP> tag.  This tag is used to loop through values and execute code multiple times.  There are several types of loops: COLLECTION, WHILE, LIST, QUERY, and FOR.  For examples of these loops see pages 832/833 in The ColdFusion 4.0 Web Application Construction Kit manual.

 

3.      <CFQUERY> tag.  This tag is used to submit an SQL statement to an existing database.  The basic components needed for this tag are a datasource and SQL statement.  In order to be able to refer to the results of the query later, it is necessary to assign a query name as well.  The basic structure is as follows: 

 

            <CFQUERY datasource=”databasename” name=”queryname”>

                        SQL statement

            </CFQUERY>

 

      If you want help on writing SQL then use the query builder in Access and cut and paste the SQL into your ColdFusion code.