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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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#""
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.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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>
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
traportAuthor Commented:
Ah... thank you! Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.