<!--- This example shows how to use the WriteOutput
      function. It calls the CF_ADDEMPLOYEE custom tag,
      which uses the addemployee.cfm file. --->
<html>
<head>
<title>WriteOutput Function</title>
</head>

<BASEFONT FACE="Arial, Helvetica" SIZE=2>
<BODY  bgcolor="#FFFFD5">
<H1>WriteOutput Function</h1>
<h3>Add New Employees</h3>
<!--- 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);
     WriteOutput("<HR>");
     WriteOutput("About to add " & FORM.firstname & " " & FORM.lastname);
  </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="writeoutput.cfm" method="post">
<P>First Name:&nbsp;
<INPUT name="firstname" type="text" hspace="30" maxlength="30">
<P>Last Name:&nbsp;
<INPUT name="lastname" type="text" hspace="30" maxlength="30">
<P>EMail:&nbsp;
<INPUT name="email" type="text" hspace="30" maxlength="30">
<P>Phone:&nbsp;
<INPUT name="phone" type="text" hspace="20" maxlength="20">
<P>Department:&nbsp;
<INPUT name="department" type="text" hspace="30" maxlength="30">
<P>
<input type="submit" value="OK">
</FORM>

</body>
</html>
