Check out this script:
http://www.dhtmlgoodies.co
I have used it many times and it works great
Main Topics
Browse All TopicsThis query is in place for the display:
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created ASC, myTable
</cfquery>
The field I have:
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>Due Date</FONT></B>
</TD>
When I click on 'Due Date', I want to have 'toggle sort' (sort by ASC or DESC back and forth), which will be basically:
Order by Created ASC
or
Order by Created DESC
I am thinking having a fucntion something like Order by Created <cfif ......>ASC <efelse> DESC</cfif>
What would be the best way to put 'toggle sort' on 'Due Date' and how to do it?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Check out this script:
http://www.dhtmlgoodies.co
I have used it many times and it works great
The issue I am having with function goToURL(aURL) is that:
The page is having the url like this:
default.cfm?fuse_action=Ma
and the query below comes before it hits the table for display.
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
It seems that the best way is to change "Order by Created" to ASC or DESC when the page is refreshed, so we will need to put a function to refresh the page.
For instance, if the page is clicked (in this case, refreshed), it becomes ASC; if clicked again, it becomes DESC, and so on. I think that is the beter way.
How do you resolve this issue?
This should work
<script type="text/javascript">
function goToURL(aURL)
{
self.location = aURL;
}
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
<cfparam name="url.sort" default="asc">
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>
<cfif url.sort eq "Asc">
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('default.
<cfelse>
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('default.
</cfif>
Due Date</FONT></B></TD>
I have the refresh function in place. onClick="goToURL('default.
For instance, the first refresh gives 1, then the next refresh gives 2, the 3rd refresh gives 1, the next gives 2, etc
that's "by design"
if you wish to you can eliminate the cfif
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('default.
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('default.
this gives the user the ability to choose
Business Accounts
Answer for Membership
by: SidFishesPosted on 2006-06-21 at 08:10:40ID: 16952142
you can do this with cfgrid without resubmitting the page...
.cfm?sort= desc');"> .cfm?sort= asc');">
fm?sort=as c');">
or
<script type="text/javascript">
function goToURL(aURL)
{
self.location = aURL;
}
<cfparam name="url.sort" default="asc">
<TD class=notetext2 width=1% nowrap align=middle>
<B><FONT color=EEEEEE>
<cfif url.sort eq "Asc">
<input type="button" name="desc" value="Sort Desc" onClick="goToURL('thispage
<cfelse>
<input type="button" name="asc" value="Sort Asc" onClick="goToURL('thispage
</cfif>
Due Date</FONT></B></TD>
<cfquery datasource......>
select * FROM GiftView WITH (NOLOCK)
WHERE ConstID = #myCon#
bla....
Order by Created #url.sort#, myTable
</cfquery>
you could also use an img
<img src="up_arrow.gif" alt="Sort Asc" onClick="goToURL('mypage.c