Chapter 5: Making Variables Dynamic
<!-- 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
Once you have created the input form, you can then create the action page to process
the user's request. This action page will determine where the user has entered search
criteria and search based only on those criteria.
To create the action page:
1.
Create a new application page in Studio.
2.
Enter the following code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<CFQUERY NAME="GetEmployees" DATASOURCE="CompanyInfo">
4
SELECT *
4
FROM Employees
4
WHERE 0=0
4
4
<CFIF #Form.FirstName# is not "">
4
AND Employees.FirstName LIKE '#form.FirstName#%'
4
</CFIF>
4
<CFIF #Form.LastName# is not "">
4
AND Employees.LastName LIKE '#form.LastName#%'
4
</CFIF>
4
<CFIF #Form.Salary# is not "">
4
AND Employees.Salary >= #form.Salary#
4
</CFIF>
4
<CFIF isDefined("Form.Contract") IS "YES">
4
AND Employees.Contract = 'Yes'
4
<CFELSE>
4
AND Employees.Contract = 'No'
4
</CFIF>
</CFQUERY>
<H3>Employee Data Based on Criteria from Form</H3>
askemp.cfm
<TITLE>Get Employee Data</TITLE>
.
55