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:
   http://staffnetdev.rti.org/research/pdo/apps/spdr_rev/dsp_trackingAdminTest.cfm?PRAStab6

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:
http://staffnetdev.rti.org/research/pdo/apps/spdr_rev/dsp_trackingAdminTest.cfm?sortOrder=client_org_name#PRAStab6

I don't know how to include this anchor along with this variable. I've tried switching the # around. Nothing seems to work.
traportAsked:
Who is Participating?

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

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

HyperBPPCommented:
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
0
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#""
0
HyperBPPCommented:
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.
0
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).
0
HyperBPPCommented:
What broswer are you using?
0
erikTsomikSystem Architect, CF programmer Commented:
you only need to use double when you need to dispaly 1#
0
traportAuthor Commented:
I'm using IE8.
0
dwkdCommented:
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>
0
HyperBPPCommented:
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.
<script>
var sortOrder = "";
function getSortOrder(queryString){
	sortOrder=getQueryStringKey('sortOrder',queryString);
	sortOrder=sortOrder.split('#')[0];
	alert(sortOrder);
	return sortOrder;
}

function getQueryStringKey(searchKey, queryString){
	if(queryString == undefined){
		queryString = window.location.search.substring[1] || "";
	}else{
		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]; 
		}
	}
}
</script>


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

<cfoutput>
	<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>
</cfoutput>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a name="PRAStab1234">PRAStab1234</a>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a name="PRAStab4321">PRAStab4321</a>

Open in new window

0

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!
0
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.