Link to home
Start Free TrialLog in
Avatar of traport
traport

asked on

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.
Avatar of HyperBPP
HyperBPP

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
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.
Avatar of traport

ASKER

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?
you only need to use double when you need to dispaly 1#
Avatar of traport

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of HyperBPP
HyperBPP

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of traport

ASKER

Ah... thank you! Thank you!