Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


IsDefined is ideal for handling radio button and check box form controls. The problem with both of these controls is that no name/value pairs are passed for them if nothing is selected. In the following set of check boxes, for example:

<B>Additional Pizza Toppings</B>
<INPUT TYPE=“TEXT” NAME=“TOPPING” VALUE=“Pepperoni”> Pepperoni
<INPUT TYPE=“TEXT” NAME=“TOPPING” VALUE=“Mushrooms”> Mushrooms
<INPUT TYPE=“TEXT” NAME=“TOPPING” VALUE=“Pineapple”> Pineapple
<INPUT TYPE=“TEXT” NAME=“TOPPING” VALUE=“Onions”> Onions
<INPUT TYPE=“TEXT” NAME=“TOPPING” VALUE=“Anchovies”> Anchovies

a user may not select any of them. You could check for this in the template that processes the pizza order form as follows:

<CFIF IsDefined(‘Form.Topping’)>
     ... extra topping processing code ...
<CFELSE>
     You did not select any extra toppings.
</CFIF>

If the user did select extra toppings, Form.Topping will be defined and ColdFusion will execute the block of code that processes the user’s selections.


By naming all the check boxes with the same NAME attribute, any selected check box values will be passed to ColdFusion as a list. If a user selects pepperoni, onions, and anchovies, for example, the value of Form.Topping would be Pepperoni,Onions,Anchovies, and you could process the toppings like so:
<CFIF IsDefined(‘Form.Topping’)>
   <CFSET ToppingList = #Form.Topping#>
   You requested the following additional toppings:
   <UL>
   <CFLOOP LIST=“ToppingList” INDEX=“top”>
      <CFOUTPUT><LI>#top#</CFOUTPUT>
   </CFLOOP>
   </UL>
<CFELSE>
   You did not select any extra toppings.
</CFIF>

The URLEncodedFormat function is essential if you plan to pass strings of data on a URL. Recall that the browser encodes form data before sending it, doing things such as replacing spaces with plus signs (+) and replacing special characters with hexadecimal escape codes. To have to do this conversion yourself would be nightmarish, but thankfully the URLEncodedFormat function spares you the agony.

URLEncodedFormat is especially useful when you are setting up links that users can click to invoke other templates. For example:

<CFQUERY DATASOURCE=“sales” NAME=“GetAll”>
SELECT ID, region
FROM Territories
</CFQUERY>

<B>Please click a region’s ID number for more information.</B>
<P>
<TABLE>
<TR><TH>ID</TH><TH>Region</TH></TR>
<CFOUTPUT QUERY=“GetAll”>
<TR>
<TD>
<A HREF=”regiondetail.cfm?region=#URLEncodedFormat(region)#>#ID#</A>
</TD>
<TD>#region#</TD>
</TR>
</CFOUPTUT>
</TABLE>

If region had the value Central Region, for example, it would need to be converted to Central+Region before passing it on the URL for the regiondetail.cfm template. In the code above, the URLEncodedFormat function takes care of this conversion for you.


NOTE:  If you’re familiar with JavaScript, the URLEncodedFormat function does the same thing as the JavaScript escape function.

Using ColdFusion Studio

As you’ve seen throughout the chapter, CFML code coexists in the same file as HTML code. Therefore, ColdFusion templates have to be plain text files, just as HTML documents are. So technically, all you need to write ColdFusion templates is an editor that can write out plain text files. This means that you could compose your templates using Notepad, Microsoft Word, or any HTML authoring tool that enables you to edit the raw code.

Although any text editor is fine, you should seriously consider using Allaire’s ColdFusion Studio as your development tool of choice for ColdFusion templates. Based on the popular HTML authoring program HomeSite, ColdFusion Studio comes with many helpful features that directly support you as you write CFML code. This final section of the chapter introduces you to ColdFusion Studio and how to use Studio to make your development work much less tedious.

The ColdFusion Studio Interface

Figure 34.20 shows the ColdFusion Studio user interface. The interface is toolbar oriented, and you have the option of displaying any or none of the toolbars. Additionally, you can customize many of the toolbars to include only the buttons you use frequently or buttons that you create.


FIGURE 34.20  The ColdFusion Studio user interface strongly resembles that of HomeSite.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.