Results 1 to 3 of 3

Thread: Text from hyperlink

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hi,
    I have what is probably a small issue, but my insight into HTML / ASP is limited.

    I have two pages results.asp and clubdetails.asp

    results.asp displays results from a query and one of the fields displayed is a hyperlink to another page. What I require is that when the hyperlink is clicked and directed to the relevant page, then I can retrieve the TEXT of the hyperlink from the previous page.

    e.g.

    Pub Inn 10/31/00 Hip Hop Casual DJ Night Free First Drink 2.00

    The "DJ Night" text is a hyperlink to clubdetails.asp. From clubdetails.asp I need to retrieve the text "DJ Night" from the previous page i.e. whatever the user clicked on.

    Hope this is clear.

    thanks in advance.

    Lenin

  2. #2
    Guest
    One way to do would be to use the QueryString:

    Change your link on the first page from:

    <A HREF="clubdetails.asp">DJ Night</A>
    to
    <A HREF="clubdetails.asp?topic=DJ%20Night">DJ Night</A>

    This causes 'topic=DJ Night' to be passed in the QueryString to clubdetails.asp (the %20 is needed to properly encode the space in 'DJ Night' in the URL). The QueryString contains everything after the '?' in the URL.

    In your cluddetails.asp you can extract the 'topic' from the QueryString with:

    Code:
    '  Parse out the value of "topic".
    strTopic = Mid(Request.QueryString, InStr(1, Request.QueryString, "=") + 1)
    '  Convert hex to spaces if necessary.
    strTopic = Replace(strTopic, "%20", " ")
    Normally the QueryString contains name/value pairs like 'name1=value1' (multiple values can be seperated with ampersands, like 'name1=value1&name2=value2' but require more sophisticated parsing in the receiving ASP). You could ditch the 'name=' part and just use a URL like:
    <A HREF="clubdetails.asp?DJ%20Night">DJ Night</A>
    which would cause the QueryString in clubdetails.asp to simply be 'DJ%20Night' (without the 'topic=' part). Then all you'd need to extract what's being passed is:
    strTopic = Replace(Request.QueryString, "%20", " ")
    to get the topic being passed. It wouldn't be exactly standard but it'd work.

    Good luck,
    Paul


    [Edited by PWNettle on 10-20-2000 at 07:56 PM]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Paul,
    many thanks. This is exactly what I required.

    Lenin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width