home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfparam.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.3 KB  |  49 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. <BODY bgcolor=silver>
  23.  
  24. <H3>CFPARAM Example</H3>
  25. <P>CFPARAM is used to set default values so that
  26. the developer does not need to check for the existence
  27. of a variable using a function like IsDefined.
  28.  
  29. <P>The default value of our tempVar is "<CFOUTPUT>#StoreTempVar#</CFOUTPUT>"
  30.  
  31. <!--- check if tempVar is still the same as StoreTempVar
  32. and that tempVar is not blank --->
  33. <CFIF tempVar is not #StoreTempVar# and tempVar is not "">
  34. <H3>The value of tempVar has changed: the new value
  35. is <CFOUTPUT>#tempVar#</CFOUTPUT></H3>
  36. </CFIF>
  37.  
  38. <P>
  39. <FORM ACTION="cfparam.cfm" METHOD="POST">
  40. Type in a new value for tempVar, and hit submit:<BR>
  41. <INPUT TYPE="Text" NAME="tempVar">
  42.  
  43. <INPUT TYPE="Submit" NAME="" VALUE="submit">
  44.  
  45. </FORM>
  46.  
  47. </BODY>
  48. </HTML>       
  49.