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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title tag on image 1

Status
Not open for further replies.

hamish75

Technical User
Dec 18, 2009
39
GB
i am displaying a logo in a response.write statement. the logo i am retrieving from a sql server 2008 database.

i wanted to display another field from the same record that would give a title description of the image so i did the following:

Code:
Response.Write ">" & "<img src=""logo.asp?id=" & slogo & """ align=""absmiddle"" width=""150"" height=""115"" border=""0"" [COLOR=red]title=" & server.UrlEncode(description)[/color] & ">"

the above code works apart from it is putting a + symbol where a space should be. if i remove the server.urlencode it does not display the full description, only the first word.

can anyone help me so it will not display the + symbol?

thanks.




Ah dinnae ken...
 
you may get away with wrapping the
Code:
server.urlencode
in a
Code:
server.urldecode
to reverse it, can you provide some HTML source of the output page, a little more of your code and some sample data ?

the + is added as that is how URLEncode encodes a space.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
i gave that a go, and it gave the following error:

Object doesn't support this property or method: 'UrlDecode'

the data type for the description is varchar(50)

it looks like this with the + symbol: Product+Code+T5+For+Stock+ID+12

on the page I have an sql statement then I output then images:

Code:
slogo =  rs("LogoID")
description = rs ("Description")
			
Response.Write ">" & "<img src=""logo.asp?id=" & slogo & """ align=""absmiddle"" width=""150"" height=""115"" border=""0"" title=" & server.UrlEncode(description) & ">"




Ah dinnae ken...
 
ok think the method name is wrong in that case :( also the usual tag for an image hover text is ALT not TITLE, can you provide the HTML source output as it originally was ?

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Yes, I did originally use the ALT but I thought TITLE would be better? as the ALT tag didn't appear in my Firefox browser.

Sorry greg. I'm not sure what to provide regarding the HTML source output.

I thought output is an image and the description "hover over" just displays as Product+Code+T5+For+Stock+ID+12.

When I call the description separately it displays as without the + symbols.



Ah dinnae ken...
 
I guess I must not be seeing something. You are trying to write some text in the alt and title attributes of an image (you should write both by the way in my opinion). I don't think it needs to be url encoded or html encoded or anything encoded or decoded. It's just text. Try writing it as just text.


Response.Write ">" & "<img src='logo.asp?id=" & slogo & "' align='absmiddle' width='150' height='115' border='0' title='" & description & "' alt='" & description & "'>"
 
Apologies, I should have mentioned I already tried doing this as text.

When I do this it only shows the first word:

So it would show

Product

instead of:

Product+Code+T5+For+Stock+ID+12


Ah dinnae ken...
 
do not ommit the quotes!

the result of your script must produce:

title="Product+Code+T5+For+Stock+ID+12"


now it is

title=Product+Code+T5+For+Stock+ID+12


 
Do you mean I'm missing quotes from this section?

Code:
title=" & server.UrlEncode(description) & ">"

I've had a play but can't figure how to change this.

Ah dinnae ken...
 
I see
Code:
Response.Write "<img src=""logo.asp?id=" & slogo & """ align=""absmiddle"" width=""150"" height=""115"" 
...etc

but with the title you do not use the double quote:
Code:
title=" & server.UrlEncode(description) & ">"


change that into
Code:
title=""" & description & """>"


you'l be in trouble when "description" contains a ".
if you are sure that will never happen leave it. otherwise consider:

Code:
title=""" & replace(description,"""","'") & """>"









 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top