home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / structinsert.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.1 KB  |  66 lines

  1. <!--- This example shows how to use the StructInsert
  2.       function. It calls the CF_ADDEMPLOYEE custom tag,
  3.       which uses the addemployee.cfm file. --->
  4. <html>
  5. <head>
  6. <title>StructInsert Function</title>
  7. </head>
  8.  
  9. <body bgcolor-"silver">
  10. <h1>StructInsert Example</h1>
  11. <h3>Add New Employees</h3>
  12. <P>
  13. This example uses the StructInsert 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.  
  36.   <P>First name is #StructFind(employee, "firstname")#</p>
  37.   <P>Last name is #StructFind(employee, "lastname")#</p>
  38.   <P>EMail is #StructFind(employee, "email")#</p>
  39.   <P>Phone is #StructFind(employee, "phone")#</p>
  40.   <P>Department is #StructFind(employee, "department")#</p>
  41.   </cfoutput>
  42.  
  43.   <!--- Call the custom tag that adds employees --->
  44.   <CF_ADDEMPLOYEE EMPINFO="#employee#">
  45. </cfif>
  46.  
  47. <hr>
  48. <FORM action="structinsert.cfm" method="post">
  49. <P>First Name: 
  50. <INPUT name="firstname" type="text" hspace="30" maxlength="30">
  51. <P>Last Name: 
  52. <INPUT name="lastname" type="text" hspace="30" maxlength="30">
  53. <P>EMail: 
  54. <INPUT name="email" type="text" hspace="30" maxlength="30">
  55. <P>Phone: 
  56. <INPUT name="phone" type="text" hspace="20" maxlength="20">
  57. <P>Department: 
  58. <INPUT name="department" type="text" hspace="30" maxlength="30">
  59.  
  60. <P>
  61. <input type="submit" value="OK">
  62. </FORM>
  63.  
  64. </body>
  65. </html>
  66.