HREF with named anchor and CF variable

I have a link that contains a variable and an anchor. The anchor is PRAStab + a variable.

Without any additional variables, when this is clicked:
   <a href="dsp_trackingAdminTest.cfm?PRAStab#qry_getTracking.trackingUnitID#">Link</a>

this is the url in the browser:

This one works.

My problem is, I can't seem to add any additional variables or it stops reading the anchor. When I try to add another variable (sortOrder) like this:
   <a href="dsp_trackingAdminTest.cfm?sortOrder=client_org_name##PRAStab#qry_getTracking.trackingUnitID#">link</a>

The browser reads it like this:

I don't know how to include this anchor along with this variable. I've tried switching the # around. Nothing seems to work.
Who is Participating?
HyperBPPConnect With a Mentor Commented:
Are you expecting the querystring to be sent back to the server?  I believe that anchors are completely client side.  I slapped together a little code that works on IE8 and FF.

When you click a link, it uses javascript to get the sortOrder, and then goes to the anchor.
var sortOrder = "";
function getSortOrder(queryString){
	return sortOrder;

function getQueryStringKey(searchKey, queryString){
	if(queryString == undefined){
		queryString =[1] || "";
		queryString = queryString.split("?")[1];	
	keys = queryString.split("&"); 
	for (i=0;i<keys.length;i++) { 
		key = keys[i].split("="); 
		if (key[0] == searchKey) { 
			return key[1]; 

<cfset qry_getTracking.trackingUnitID = "1234"/>
<cfset test2 = "4321"/>

	<a href="dsp_trackingAdminTest.cfm?sortOrder=client_org_name##PRAStab#qry_getTracking.trackingUnitID#" onClick="getSortOrder(this.href)">client_org_name</a><br/>
	<a href="dsp_trackingAdminTest.cfm?sortOrder=client_last_name##PRAStab#test2#" onClick="getSortOrder(this.href)">client_last_name</a>
<a name="PRAStab1234">PRAStab1234</a>
<a name="PRAStab4321">PRAStab4321</a>

Open in new window

According to the RCF the URL is split by the fragment identifier first (#), if present, and *then* parsed as an address. It's therefore imperative that the fragment identifier is placed last in the URL, which may also be combined with a query string
erikTsomikSystem Architect, CF programmer Commented:
you can put it into the variable and then pass it to the url.
<cfset url_variable= ID>

Also i noticed that in your url you have an extra #.

Also in order to pass multiple url variables they need to be separated by &

For example
<a href="page.cfm?Variable1=#id#&variable2="#id2#""
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

You might try    <a href="dsp_trackingAdminTest.cfm?sortOrder=client_org_name&1=1##PRAStab#qry_getTracking.trackingUnitID#">link</a>

Since you don't care about the 1=1, it doesn't matter if it gets corrupted.
traportAuthor Commented:
Thanks all for the replies.

HyperBPP: I don't understand what you're saying. The anchor is the last in the URL here if that's what you mean. Changing it to add the 1=1 doesn't work for some reason, either.

erikTsomik: I'm going to try your suggestion and may not be back until tomorrow just to let you know. I have an extra # b/c that's what you have to have in CFML so that it reads # which I used to indicate it was an anchor (in CFML I have to use double # when I'm w/in cfoutput).
What broswer are you using?
erikTsomikSystem Architect, CF programmer Commented:
you only need to use double when you need to dispaly 1#
traportAuthor Commented:
I'm using IE8.
correct me if i'm wrong but you want the end result to look something like <a href="dsp_trackingAdminTest.cfm?sortOrder=client_org_name#PRAStab12345">link</a>
if so, do something like
<cfset AnchorId = "PRAStab#qry_getTracking.trackingUnitID#">
<a href="dsp_trackingAdminTest.cfm?sortOrder=client_org_name###AnchorId#">link</a>
traportAuthor Commented:
Ah... thank you! Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.