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 / structclear.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.9 KB  |  67 lines

  1. <!--- This example shows how to use the StructClear
  2.       function. It calls the CF_ADDEMPLOYEE custom tag,
  3.       which uses the addemployee.cfm file. --->
  4. <html>
  5. <head>
  6. <title>StructClear Function</title>
  7. </head>
  8. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  9. <BODY  bgcolor="#FFFFD5">
  10. <h1>StructClear Function</h1>
  11. <h3>Add New Employees</h3>
  12. <P>
  13. This example uses the StructClear function. To run this snippet
  14. under UNIX, you must add employee ID generation logic 
  15. to the addemployee.cfm file.
  16. <!--- Establish parms for first time through  --->
  17. <CFPARAM name="FORM.firstname" default="">
  18. <CFPARAM name="FORM.lastname" default="">
  19. <CFPARAM name="FORM.email" default="">
  20. <CFPARAM name="FORM.phone" default="">
  21. <CFPARAM name="FORM.department" default=""> 
  22.  
  23. <CFIF #FORM.firstname# EQ "">
  24.  <P>Please fill out the form.
  25. <CFELSE>
  26.   <CFOUTPUT>
  27.    <CFSCRIPT>
  28.      employee=StructNew();
  29.      StructInsert(employee, "firstname", FORM.firstname);
  30.      StructInsert(employee, "lastname", FORM.lastname);
  31.      StructInsert(employee, "email", FORM.email);
  32.      StructInsert(employee, "phone", FORM.phone);
  33.      StructInsert(employee, "department", FORM.department); 
  34.    </CFSCRIPT> 
  35.   </cfoutput>
  36.  
  37.   <!--- Call the custom tag that adds employees --->
  38.   <CF_ADDEMPLOYEE EMPINFO="#employee#">
  39.   <CFSCRIPT>StructClear(employee);</CFSCRIPT>  
  40.  </cfif>
  41.  
  42. <hr>
  43. <FORM action="structclear.cfm" method="post">
  44. <P>First Name: 
  45. <INPUT name="firstname" type="text" hspace="30" maxlength="30">
  46. </p>
  47. <P>Last Name: 
  48. <INPUT name="lastname" type="text" hspace="30" maxlength="30">
  49. </p>
  50. <P>EMail: 
  51. <INPUT name="email" type="text" hspace="30" maxlength="30">
  52. </p>
  53. <P>Phone: 
  54. <INPUT name="phone" type="text" hspace="20" maxlength="20">
  55. </p>
  56. <P>Department: 
  57. <INPUT name="department" type="text" hspace="30" maxlength="30">
  58. </p>
  59.  
  60. <P>
  61. <input type="submit" value="OK">
  62. </p>
  63. </FORM>
  64.  
  65. </body>
  66. </html>
  67.