
Dynamic SQL
97
Creating the input form
First, you need to create an input form, which asks for information about several
fields in the Employee table. To search for data based on only the fields the user
enters in the form, you use
cfif
statements in the SQL statement.
To create the input form:
1
Create a new application page in ColdFusion Studio.
2
Enter the following code:
<html>
<head>
<title>Input form</title>
</head>
<body>
<!--- Query the Employee table to be able to populate the form --->
<cfquery name="AskEmployees" datasource="CompanyInfo">
SELECT
FirstName,
LastName,
Salary,
Contract
FROM Employee
</cfquery>
<!--- define the action page in the form tag. The form variables will
pass to this page when the form is submitted --->
<form action="getemp.cfm" method="post">
<!-- text box -->
<p>First Name: <input type="Text" name="FirstName" size="20"
maxlength="35"><br>
Last Name: <input type="Text" name="LastName" size="20"
maxlength="35"><br>
Salary: <input type="Text" name="Salary" size="10" maxlength="10">
</p>
<!-- check box -->
<p>Contractor? <input type="checkbox" name="Contract" value="Yes"
>Yes if checked
</p>
<!-- reset button -->
<input type="reset" name="ResetForm" value="Clear Form">
<!-- submit button -->
<input type="submit" name="SubmitForm" value="Submit">
</form>
</body>
</html>
3
Save the page as
askemp.cfm
.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...