Third addition to querystring failing to appear

B

Bill

I've got a hyperlink that unfolds with the following info on it:
response.write "<td><font face=verdana size=1><a
href=v_detail_products.asp?price=" & price _
& "&isbn=" & isbn & ">" & rs("title") & "</a></td>"

The _ following price is where the line ends and wraps to the next
line. This current set up works fine. However, mysteriously, if I try
adding a third variable to this line, called title, it fails to appear
at all, not only the content of the variable, but the hard text it
self, as it it was not even entered. For example:
response.write "<td><font face=verdana size=1><a
href=v_detail_products.asp?price=" & price _
& "&isbn=" & isbn & "&title=" & rs("title") & ">" & rs("title") &
"</a></td>"

Not only will the contents of rs("title") not appear, but the string
"&title" will not appear in the hyperlink, as if the word title was
not being recognized for some reason. Can someone answer this mystery
for me?

Thanks,

Bill
 
A

Adrienne

Gazing into my crystal ball I observed (e-mail address removed) (Bill)
writing in
I've got a hyperlink that unfolds with the following info on it:
response.write "<td><font face=verdana size=1><a
href=v_detail_products.asp?price=" & price _
& "&isbn=" & isbn & ">" & rs("title") & "</a></td>"

The _ following price is where the line ends and wraps to the next
line. This current set up works fine. However, mysteriously, if I try
adding a third variable to this line, called title, it fails to appear
at all, not only the content of the variable, but the hard text it
self, as it it was not even entered. For example:
response.write "<td><font face=verdana size=1><a
href=v_detail_products.asp?price=" & price _
& "&isbn=" & isbn & "&title=" & rs("title") & ">" & rs("title") &
"</a></td>"

Not only will the contents of rs("title") not appear, but the string
"&title" will not appear in the hyperlink, as if the word title was
not being recognized for some reason. Can someone answer this mystery
for me?

Thanks,

Bill

<td><font face="verdana" size="1"><a href="v_detail_products.asp?price=<%
=price%>&amp;isbn=<%=isbn%>&amp;title=<%=rs("title")%>"><%=rs("title")%>
</a></font></td>

OR:

response.write "<td><font face=" &chr(034) & "verdana" & chr(034) & "
size=" & chr(034) & "1" & chr(034) & "><a href=" & chr(034) &
"v_detail_products.asp?price=" & price & "&isbn=" & isbn & "&title=" & rs
("title") & chr(034) & ">" & rs("title") & "</a></font></td>"

You will notice that every attribute has been quoted. It is always a good
idea to quote attributes, even though HTML 4 does not require it for
numbers, only text. Probably in your case, you are missing some quote
marks. You also did not close the font element, which could potentially
cause issues.

By the way, just to let you know, the font element is depreciated in favor
of CSS. Additionally, you should specify fonts in addition to Verdana, eg,
Arial, Helvetica and add sans-serif as the fall back.

If you use option 1 above, make sure to escape & using &amp;
 
B

Bullschmidt

Perhaps Server.URLEncode() would help as described below.

Example URL with a querystring:
http://www.mysite.com/mydir/mypg.asp?myvar1=hey&myvar2=ho

Because a variable might contain some odd characters like spaces, it's
usually a good idea to use Server.URLEncode when creating a querystring
from a variable:
<a href="http://www.mysite.com/mypage?id=<%=
Server.URLEncode(objRS("MyIDFldFromDB")) %>">objRS("MyIDFldFromDB")</a>

And in the page that is opened you can use Request.QueryString("id") to
get the value of id.

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top