I am so close! I figured out how to pass the selected value
from the cfselect to the cfc, but now I cannot seem to make the
query run with the passed value. Here's the cfm:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>View Jobs Filtered By State</title>
</head>
<body>
<cfif isdefined ("form.ddlStates")>
<cfset form.selectedState="#form.ddlStates#">
<cfelse>
<cfset selectedState="">
</cfif>
<cfinvoke
component="cfc.jobsByState"
method="getJobsByState"
returnvariable="qryGetJobsByState">
<cfinvokeargument name="selectedStateToPass"
value=#selectedState#>
</cfinvoke>
<cfform format="html" method="post"
action="viewFilteredJobs.cfm">
<table border="0" align="center">
<tr><td><a href="viewFilteredJobs.cfm"
style="font-size:11px;font-family:Arial">Go
Back</a></td></tr>
<tr><td>
<cfselect name="ddlStates">
<option value="Alabama" label="Alabama">
<option value="Alaska" label="Alaska">
<option value="Arizona" label="Arizona">
<option value="Colorado" label="Colorado">
<option value="Maryland" label="Maryland">
</cfselect>
<cfinput type="submit" name="Submit" value="Submit"
style="font-size:11px;font-family:Arial">
<cfoutput>#selectedState#</cfoutput>
</td>
</tr>
<tr>
<td colspan="3">
<cfgrid name="grdJobsByState" selectmode="row"
griddataalign="center" pagesize="30" format="html"
bind="cfc:cfc.jobsByState.getJobsByState({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">
<cfgridcolumn name="jobtitle" header="Job Title"
headeralign="center" width="500" dataalign="left">
<cfgridcolumn name="certified" header="Cert/Lic Req?"
headeralign="center" width="100" dataalign="center">
<cfgridcolumn name="searchstate" header="State"
headeralign="center" width="50" dataalign="center">
<cfgridcolumn name="date" header="Date"
headeralign="center" width="150" dataalign="center">
</cfgrid>
</td>
</tr>
</table>
</cfform>
</body>
</html>
And here's the cfc:
<cfcomponent>
<cffunction name="getJobsByState" access="remote">
<cfargument name="page" required="yes" default="1">
<cfargument name="pageSize" required="yes"
default="20">
<cfargument name="gridsortcolumn" required="yes"
default="date">
<cfargument name="gridsortdirection" required="yes"
default="desc">
<cfargument name="selectedStateToPass" required="yes"
default="">
<cfif arguments.gridsortcolumn eq "">
<cfset arguments.gridsortcolumn="date" />
<cfset arguments.gridsortdirection="desc" />
<cfset
arguments.selectedStateToPass='#selectedStateToPass#' />
</cfif>
<cfquery name="qryGetJobsByState"
datasource="ttcmdev_local">
EXEC sp_GetJobsByState
@state='#selectedStateToPass#'
</cfquery>
<cfreturn queryconvertforgrid(qryGetJobsByState, page,
pagesize)>
</cffunction>
</cfcomponent>
I know that my cfselect value is getting passed because in
debug mode, I can select a state from the cfselect. submit the
form, and see the variable passed to the stored procedure in the
SQL Queries section of the debug info:
qryGetJobsByState (Datasource=ttcmdev_local, Time=15ms,
Records=68) in C:\Inetpub\wwwroot\Demo\cfc\jobsByState.cfc @
11:44:42.042
EXEC sp_GetJobsByState
@state='Colorado'
Please help me! I'm almost there!