home *** CD-ROM | disk | FTP | other *** search
- <!--- This example shows how to use the StructInsert
- function. It calls the CF_ADDEMPLOYEE custom tag,
- which uses the addemployee.cfm file. --->
- <html>
- <head>
- <title>StructInsert Function</title>
- </head>
-
- <BASEFONT FACE="Arial, Helvetica" SIZE=2>
- <BODY bgcolor="#FFFFD5">
-
- <h3>StructInsert Example</h3>
- <h3>Add New Employees</h3>
- <P>
- This example uses the StructInsert function. To run this snippet
- under UNIX, you must add employee ID generation logic
- to the addemployee.cfm file.
- <!--- Establish parms for first time through --->
- <CFPARAM name="FORM.firstname" default="">
- <CFPARAM name="FORM.lastname" default="">
- <CFPARAM name="FORM.email" default="">
- <CFPARAM name="FORM.phone" default="">
- <CFPARAM name="FORM.department" default="">
-
- <CFIF #FORM.firstname# EQ "">
- <P>Please fill out the form.
- <CFELSE>
- <CFOUTPUT>
- <CFSCRIPT>
- employee=StructNew();
- StructInsert(employee, "firstname", FORM.firstname);
- StructInsert(employee, "lastname", FORM.lastname);
- StructInsert(employee, "email", FORM.email);
- StructInsert(employee, "phone", FORM.phone);
- StructInsert(employee, "department", FORM.department);
- </CFSCRIPT>
-
- <P>First name is #StructFind(employee, "firstname")#</p>
- <P>Last name is #StructFind(employee, "lastname")#</p>
- <P>EMail is #StructFind(employee, "email")#</p>
- <P>Phone is #StructFind(employee, "phone")#</p>
- <P>Department is #StructFind(employee, "department")#</p>
- </cfoutput>
-
- <!--- Call the custom tag that adds employees --->
- <CF_ADDEMPLOYEE EMPINFO="#employee#">
- </cfif>
-
- <hr>
- <FORM action="structinsert.cfm" method="post">
- <P>First Name:
- <INPUT name="firstname" type="text" hspace="30" maxlength="30">
- <P>Last Name:
- <INPUT name="lastname" type="text" hspace="30" maxlength="30">
- <P>EMail:
- <INPUT name="email" type="text" hspace="30" maxlength="30">
- <P>Phone:
- <INPUT name="phone" type="text" hspace="20" maxlength="20">
- <P>Department:
- <INPUT name="department" type="text" hspace="30" maxlength="30">
-
- <P>
- <input type="submit" value="OK">
- </FORM>
-
- </body>
- </html>
-