Evert Jor
asked on
Need help with hyperlink syntax in ASP
I'm trying to insert a hyperlink in the following line, but I can't get the syntax right. I need a hyperlink to open in a new page inserted where the text "Hyperlink" is below:
if showproductid=TRUE then print "<div class=""detailid""><strong>" & xxPrId & ":</strong> <span itemprop=""productID"">" & rs("pID") & "Hyperlink"&"</span></div>"
if showproductid=TRUE then print "<div class=""detailid""><strong>" & xxPrId & ":</strong> <span itemprop=""productID"">" & rs("pID") & "Hyperlink"&"</span></div>"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you want a link to open a new page
if showproductid then print "<div class='detailid'><strong>" & xxPrId & ":</strong><span itemprop='productID'><a href='??page url here??' target='_blank'>" & rs("pID") & "</a></span></div>"
First, look at what the output should be for the HTML. https://www.w3schools.com/tags/att_a_target.asp The example there is
So your example should be something like below. I may have some of the rendered HTML wrong, I was just guessing based on the code you provided.
HainKurt said right away to use single quotes instead of double quotes because it makes it easier. In other words, instead, of below
You will find the result is the same when you render the page.
Putting it all together.
That should work out to
<a href="https://www.w3schools.com" target="_blank">Visit W3Schools</a>
So your example should be something like below. I may have some of the rendered HTML wrong, I was just guessing based on the code you provided.
<div class="detailid"><strong> SOME_TEXT </strong> <span itemprop="productID">123 <a href="https://www.w3schools.com" target="_blank">Visit W3Schools</a> </span></div>
HainKurt said right away to use single quotes instead of double quotes because it makes it easier. In other words, instead, of below
response.write "<a href=""https://www.w3schools.com"" target=""_blank"">Visit W3Schools</a>"
it is much easier to useresponse.write "<a href='https://www.w3schools.com' target='_blank'>Visit W3Schools</a>"
You will find the result is the same when you render the page.
Putting it all together.
showproductid = "TRUE"
detailid = 123
xxPrId ="abc"
productID ="xyz"
' rs("pID") recordset assume 789
' ASSUME HYPERLINK IS ON rs("pID")
if showproductid = "TRUE" then
response.write "<div class='" & detailid & "'><strong>'" & xxPrId & "</strong> <span itemprop='"&productID&"'><a href='"& rs("pID") & "' target='_blank'>" & rs("pidD") & "</a> </span></div>"
end if
That should work out to
<div class="123><strong>abc</strong> <span itemprop="xyz"><a href="789">789</a> </span></div>
I have not tested, and may have a typo, but give it a try
Open in new window