Using a Variable in an <a href statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malineau
    New Member
    • Mar 2007
    • 3

    Using a Variable in an <a href statement

    I would like to be able to open a link utilising a variable as the destination. Something like <a href=variablena me><\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!
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    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="thisparagra ph">
    Some text
    </p>

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

    <a href="www.examp le.com/mypage.html#thi sparagraph">

    Clicking on that link will then jump down to that paragraph of the page.

    Comment

    • malineau
      New Member
      • Mar 2007
      • 3

      #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?pa ge=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

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        Neither html nor css would be able to do that so you would need a server side language/program.

        Comment

        • malineau
          New Member
          • Mar 2007
          • 3

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

          Comment

          • AricC
            Recognized Expert Top Contributor
            • Oct 2006
            • 1885

            #6
            Originally posted by malineau
            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

            Comment

            • natp
              New Member
              • May 2010
              • 1

              #7
              I think this is what you want:

              Code:
              <xsl:text disable-output-escaping="yes">&lt;a herf="</xsl:text>
              <xsl:value-of select="theUrl"></xsl:value-of>
              <xsl:text disable-output-escaping="yes">">Click Me&lt;/a></xsl:text>
              Sorry, for my poor typing. It should be href not herf.

              Comment

              • drhowarddrfine
                Recognized Expert Expert
                • Sep 2006
                • 7434

                #8
                We can forgive you for typos but not for bringing up 3 year old threads.

                Comment

                Working...