Can anyone help with this problem?
Page one has a drop down where the user selects a Site.
Site is passed to page two where the selection is used in a SQL where clause. That works fine.
Page two has click to sort column heading which re-loads the page with Order By info. However, when the column sort is done, it loses the earlier Site selection variable value and returns an error:
page one:
<cfparam name="TheSite" default="">
<cfquery name="getSite" datasource="data">
Select distinct site
from tbldata
order by site
</cfquery>
<cfform name="selectSite" action="page2.cfm" >
<cfselect name="TheSite"
query="getsite"
value="site"
selected="#Thesite#">
</cfselect>
<input type="submit" name="" value="go" method="post">
</cfform>
page two (page2.cfm)
<cfparam name="sort" default="1">
<cfquery name="qrydetail" datasource="data">
SELECT hltag, name, site
FROM tbldata
WHERE site = '#form.TheSite#'
ORDER BY
<cfswitch expression="#sort#">
<cfcase value="1">hltag, name</cfcase>
<cfcase value="2">hltag DESC, name</cfcase>
<cfcase value="3">name</cfcase>
<cfcase value="4">name desc</cfcase>
</cfswitch>
</cfquery>
<cfoutput>
<tr bgcolor="##E5E5E5"><!--- header row --->
<td><a href="page2.cfm?sort=#IIF(sort is 1, '2', '1')#">hltag</a></td>
<td><a href="page2.cfm?sort=#IIF(sort is 3, '4', '3')#">name</a></td>
<td>site</td>
</tr>
</cfoutput>
<cfoutput query="qrydetail"><!--- data rows --->
<tr>
<td>#qrydetails.hltag#</td>
<td>#qrydetails.name#</td>
<td>#qrydetails.site#</td>
</tr>
</cfoutput>
ERROR: Element THESITE is undefined in FORM. - WHERE site = '#form.TheSite#'
Page one has a drop down where the user selects a Site.
Site is passed to page two where the selection is used in a SQL where clause. That works fine.
Page two has click to sort column heading which re-loads the page with Order By info. However, when the column sort is done, it loses the earlier Site selection variable value and returns an error:
page one:
<cfparam name="TheSite" default="">
<cfquery name="getSite" datasource="data">
Select distinct site
from tbldata
order by site
</cfquery>
<cfform name="selectSite" action="page2.cfm" >
<cfselect name="TheSite"
query="getsite"
value="site"
selected="#Thesite#">
</cfselect>
<input type="submit" name="" value="go" method="post">
</cfform>
page two (page2.cfm)
<cfparam name="sort" default="1">
<cfquery name="qrydetail" datasource="data">
SELECT hltag, name, site
FROM tbldata
WHERE site = '#form.TheSite#'
ORDER BY
<cfswitch expression="#sort#">
<cfcase value="1">hltag, name</cfcase>
<cfcase value="2">hltag DESC, name</cfcase>
<cfcase value="3">name</cfcase>
<cfcase value="4">name desc</cfcase>
</cfswitch>
</cfquery>
<cfoutput>
<tr bgcolor="##E5E5E5"><!--- header row --->
<td><a href="page2.cfm?sort=#IIF(sort is 1, '2', '1')#">hltag</a></td>
<td><a href="page2.cfm?sort=#IIF(sort is 3, '4', '3')#">name</a></td>
<td>site</td>
</tr>
</cfoutput>
<cfoutput query="qrydetail"><!--- data rows --->
<tr>
<td>#qrydetails.hltag#</td>
<td>#qrydetails.name#</td>
<td>#qrydetails.site#</td>
</tr>
</cfoutput>
ERROR: Element THESITE is undefined in FORM. - WHERE site = '#form.TheSite#'