Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retain variable passed in a URL 2

Status
Not open for further replies.

Gill1978

Programmer
Joined
Jun 12, 2001
Messages
277
Location
GB
Hi!

I've got a cftable generated by a sql query. However i'd like to make it dynamically sortable. So to do this I have set the headings as links, which will reload the page with the variable to sort by.

But in this link i need to pass the variable originally passed in the link i.e. when the page was opened it was sent variables via the link on the previous page.

How do i retain the original url variables when the page is reloaded when a user clicks the headings?

Thanks

Julie

 
you can access all of the variables that are declared on the url by adding the URL prefix to the variable name. so if you have a querystring of index.cfm?a=1&b=2 you would access the variable a using URL.a

on each of your column header links you will need to put this code so you header column would look something like this:

<a href=&quot;yourpage.cfm?a=#URL.a#&b=#URL.b#&SortBy=this&quot;>this</A>

hope this helps !

 
Julie,
Just to add to what arperry said -- there is a variable called cgi.query_string that are all the url variables . So you could use this to quickly add all the original variables.

e.g
If you have a link like <a href=&quot;page2.cfm?var1=a&var2=b&quot;>click here</a>

On page2.cfm you can use
<cfoutput>
<a href=&quot;page2.cfm?#cgi.query_string#&var3=c&quot;>Re-sort</a>
</cfoutput>
to add the var1=a&var2=b to the link. Then you access the individual variables like arperry has stated.

I do this all the time to do exactly what you are wanting to do.

HTH,
Tim P.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top