home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfparam.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.3 KB  |  50 lines

  1. <!--- This example shows how CFPARAM operates --->
  2. <CFPARAM name="storeTempVar" default="my default value">
  3. <CFPARAM name="tempVar" default="my default value">
  4.  
  5. <!--- check if form.tempVar was passed --->
  6. <CFIF IsDefined("form.tempVar") is "True">
  7. <!--- check if form.tempVar is not blank --->
  8.     <CFIF form.tempVar is not "">
  9. <!--- if not, set tempVar to value of form.tempVar --->    
  10.         <CFSET tempVar = form.tempVar>
  11.     </CFIF>
  12. </CFIF>
  13.  
  14. <HTML>
  15.  
  16. <HEAD>
  17. <TITLE>
  18. CFPARAM Example
  19. </TITLE>
  20. </HEAD>
  21.  
  22. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  23. <BODY  bgcolor="#FFFFD5">
  24.  
  25. <H3>CFPARAM Example</H3>
  26. <P>CFPARAM is used to set default values so that
  27. the developer does not need to check for the existence
  28. of a variable using a function like IsDefined.
  29.  
  30. <P>The default value of our tempVar is "<CFOUTPUT>#StoreTempVar#</CFOUTPUT>"
  31.  
  32. <!--- check if tempVar is still the same as StoreTempVar
  33. and that tempVar is not blank --->
  34. <CFIF tempVar is not StoreTempVar and tempVar is not "">
  35. <H3>The value of tempVar has changed: the new value
  36. is <CFOUTPUT>#tempVar#</CFOUTPUT></H3>
  37. </CFIF>
  38.  
  39. <P>
  40. <FORM ACTION="cfparam.cfm" METHOD="POST">
  41. Type in a new value for tempVar, and hit submit:<BR>
  42. <INPUT TYPE="Text" NAME="tempVar">
  43.  
  44. <INPUT TYPE="Submit" NAME="" VALUE="submit">
  45.  
  46. </FORM>
  47.  
  48. </BODY>
  49. </HTML>       
  50.