By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,738 Members | 1,080 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,738 IT Pros & Developers. It's quick & easy.

Using a Variable in an <a href statement

P: 3
I would like to be able to open a link utilising a variable as the destination. Something like <a href=variablename><\a> where variablename specifies a page address within the website. But I can't work out how to parse the variable into the href statement.

Basically I'm trying to produce a sort of breadcrumb trail, such that at the top of each page a user has a sequential list of the pages he has visited up until now - these are passed url encoded (it's simple and it doesn't need to be secure). I then strip the passed variable to get the previous page name. I would just like to make the sequential list clickable, such that a user can go back to any page he has already visited.

This may be a complete waste of time, but hey, I want to do it!
Mar 14 '07 #1
Share this Question
Share on Google+
7 Replies


drhowarddrfine
Expert 5K+
P: 7,435
If you mean something like paragraph 10 of a web page, try this:

If your web site is www.example.com/mypage.html, on the tenth paragraph you would do this:

<p id="thisparagraph">
Some text
</p>

Then, in the anchor of the referring page, you would do this:

<a href="www.example.com/mypage.html#thisparagraph">

Clicking on that link will then jump down to that paragraph of the page.
Mar 14 '07 #2

P: 3
Not quite what I mean I'm afraid.

I've got the site set such that each preceeding page passes it's address to the next page via url encoding (i.e. www.site.com?page=page1.html).

The next page picks up the "page" variable. I would like to use that variable in an <a href statement, such that when I display the sequential list of previously visited pages (using the same variables passed by previous pages), they are displayed as links such that the user can use them to backtrack.

I know one can use the history in Javascript, but that doesn't give the explicit page addresses, (only -1 or -n etc ) which is not what I want.

Cheers
Mar 14 '07 #3

drhowarddrfine
Expert 5K+
P: 7,435
Neither html nor css would be able to do that so you would need a server side language/program.
Mar 14 '07 #4

P: 3
Thanks for that.

Bums - or other epithets. No wonder I couldn't find anything on the web. I take it that includes Javascript? It seems such a simple, straightforward thing.

Cheers
Mar 14 '07 #5

Expert 100+
P: 1,892
Thanks for that.

Bums - or other epithets. No wonder I couldn't find anything on the web. I take it that includes Javascript? It seems such a simple, straightforward thing.

Cheers
Yes Javascript is server side. You could do it in PHP or ASP. Here is a link to our PHP forum.

HTH,
Aric
Mar 14 '07 #6

P: 1
I think this is what you want:

Expand|Select|Wrap|Line Numbers
  1. <xsl:text disable-output-escaping="yes">&lt;a herf="</xsl:text>
  2. <xsl:value-of select="theUrl"></xsl:value-of>
  3. <xsl:text disable-output-escaping="yes">">Click Me&lt;/a></xsl:text>
  4.  
Sorry, for my poor typing. It should be href not herf.
May 28 '10 #7

drhowarddrfine
Expert 5K+
P: 7,435
We can forgive you for typos but not for bringing up 3 year old threads.
May 28 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.