MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual page 151

Table of Contents

Advertisement

Creating and Using Structures
<body>
<h1>Add New Employees</h1>
<!--- Action page code for the form at the bottom of this page --->
<!--- Establish parameters 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="">
<!--- If at least the firstaname form field is passed, create
<cfif #form.firstname# eq "">
<p>Please fill out the form.
<cfelse>
<cfoutput>
</cfscript>
<!--- Display results of creating the structure --->
<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>
<!--- The form for adding the new employee information --->
<hr>
<form action="structinsert.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>
a structure named employee and add values --->
<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#");
131

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 5

Table of Contents