Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic HREF problem

Status
Not open for further replies.

millzy7

Programmer
Dec 9, 2003
96
US
Hi,

I want the value of href to be dynamically set. I know that the link address needs to be surrounded by double quotes but dont know how to do this when inserting it with Response.write.

Session("link") is but it doesnt work when i click it. Any idea how to make this work?

Thanks

Response.Write("<td><a href = " & Session("link") & "><input type ='image' src ='camera.gif'/></a></td></tr>")
 
Try this:

<%

Session( "link" ) = "
Response.Write "<td><a href = '" & Session( "link" ) & "'><img src = 'camera.gif'></a></td></tr>"

%>

[blue]Go to work to learn. Don't go to work to earn.[/blue]
 
Use the "View Source" feature in your browser to check to find the exact HTML that is being created by your ASP. Perhaps there will be something simple and you will notice it right away. IF not, please reply here with what you found.

You can concatinate double quotes into a string like this:
MyString = "I really " & Chr(34) & "love" & Chr(34) & " to write code."

and also like this:
MyString = "I really ""love"" to write code."

to get this:
I really "love" to write code.


 
try this:

Code:
Response.Write("<td><a href = """ & Session("link") & """><input type ='image' src ='camera.gif'/></a></td></tr>")

-DNG
 
Thanks guys, using the 3 sets of double quotes worked nicely.

I'm trying this method of passing variables for the first time. How do i read the value of "x" on the target page? Is it just request.form("x")

test.asp?x=3
 
your href tag should look something like this:

href="test.asp?"&request.form("x")

-DNG
 
If the variable is being passed in an via a link

eg

<a href="nextpage.asp?UserID=100">View Record</a>

on your nextpage.asp you would assign the value you've passed from the link to your variable with:

UserID=Request.QueryString("UserID")

You can pass more than one value by using & in between them

eg

<a href="nextpage.asp?a=1&b=2&c=3">Click here</a>
 
Thanks emozley

Thats fixed it

Cheers

Millzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top