Hi,
I am passing a number of variables via URL in order to sort a
dataset. The problem I have is that if I also have a submit form on
the same page, such as a dropdown to select a certain status, or a
list of items that I can checkmark, the variable that I originally
passed with the URL seems to override whatever I enter in the form,
keep in mind that the form and the URL variable have the same name,
which they must have in order to work correctly. Is there a way to
release the passed variable when I submit on the form? Or perhaps I
should pursue a different solution for data sorting?
I've condensed the code below, the "sorter" variable is
passed by the column header so that the same criteria is passed
into the updated page in order to properly sor the same set of data
that was originally presented. But if I want to change my "sorter"
criteria to something else by selecting it from the dropdown list I
get the old "sorter" data that I was previously looking at. Somehow
I need to be able to release the "sorter" variable so that I can
submit a fresh variable. I have the same problem in different code
using check boxes to create a select list to narrow the dataset.
Thanks in advance for any suggestions.
<cfquery name="tsts" datasource="#dsname#">
SELECT *
FROM tst
where status=#stats#
order by #sort_order#
<cfif sort eq 1>
desc
</cfif>
</cfquery>
<form action="" method="post">
<table>
<cfif sort neq 1>
<th><a
href="tst.cfm?sort_order=id1&sort=1&stats=#x#>Item
1:</a></th>
<th><a
href="tst.cfm?sort_order=id2&sort=1&stats=#x#>Item
2:</a></th>
<cfelse>
<th><a
href="tst.cfm?sort_order=id1&sort=2&stats=#x#>Item
1:</a></th>
<th><a
href="tst.cfm?sort_order=id2&sort=2&stats=#x#>Item
2:</a></th>
</cfif>
<cfoutput query="tsts">
<tr>
<td>#id1#</td>
<td>#id2#</td>
</cfoutput>
</table>
<select name="stats" onChange="submit()">
<option></option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
</select>
</form>