PDA

Click to See Complete Forum and Search --> : Text from hyperlink


lenin
Oct 20th, 2000, 04:26 PM
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

Oct 20th, 2000, 06:47 PM
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:


' 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]

lenin
Oct 21st, 2000, 10:01 AM
Paul,
many thanks. This is exactly what I required.

Lenin