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 / structnew.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  2.1 KB  |  66 lines

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