Click to See Complete Forum and Search --> : Problem with alt text for images


wizeazz101
08-01-2008, 11:42 AM
I am trying to bring in a field as the alt text for an image, and all it is displaying is the first 4 characters. I am sure I am doing something weird, anybody have any ideas?

Here is the code.

<IMG SRC=/images/" & rsObj("Folder") & "/" &

rsObj("FileName") & " alt=" & rsObj("Caption") & "><br><br><b>" & rsObj("Caption") & "</b><br>"

Thanks,

Doug
www.virtualautomuseum.com

yamaharuss
08-02-2008, 08:18 AM
Try:

alt=" & Server.HTMLEncode(rsObj("Caption")) & "

wizeazz101
08-05-2008, 11:03 AM
I have tried that with the same result. Am I having problems due to trying to use the same RS data twice? My captions are "1958 Cadillac Eldorado" and all my alt text is displaying is the year, it chops it off after the first four digits.

yamaharuss
08-05-2008, 11:29 AM
Are you sure that's what your caption is?

do:

response.write("<P>my caption is - "&rsObj("Caption")&"<P>")

wizeazz101
08-05-2008, 02:31 PM
I am using this code, as well as the one you sent. They both perform the same way.

<IMG SRC=/images/" & rsObj("Folder") & "/" &

rsObj("FileName") & " alt=" & rsObj("Caption") & "><br><br><b>" & rsObj("Caption") & "</b><br>"

The second rsObj("Caption") writes just fine below the picture, but in the alt text, just gives me the first 4 characters.

Thanks

yamaharuss
08-05-2008, 02:42 PM
Your code shouldn't be working if you are writing in HTML as shown.

Should be:


<IMG SRC=/images/"<%=rsObj("Folder")%>"/"<%=rsObj("FileName")%>" alt="<%=rsObj("Caption")%>"><br><br><b><%=rsObj("Caption")%></b><br>"


If you are response.writing in ASP it is still wrong and should be:


response.write("<IMG SRC=/images/"""&rsObj("Folder")&"/"&rsObj("FileName")&""" alt="""&rsObj("Caption")&"""><br><br><b>"&rsObj("Caption")&"</b><br>")

wizeazz101
08-05-2008, 06:42 PM
Sorry, I didn't include the whole line, it is actually written in ASP. When I use the code you sent me, the file is not showing the pic, but is showing the entire alt text. This is what I end up with. The first caption is where the pic should be. When I look at the source it is putting an extra " in front of the folder name, so it is not finding the pic. Sorry I am not as good at this stuff as I should be.

1991 Lotus Elan SE Turbo Roadster

1991 Lotus Elan SE Turbo Roadster
Photo Courtesy of Allon White Sports Cars

wizeazz101
08-05-2008, 07:26 PM
YamahaRuss,

Thank you for your assistance, I took your code and played with it a bit and finally got it. I am not an extremely good coder, self taught, and only learn what I need to know to accomplish a task. Here is the piece of code that I was finally able to make work.

response.write "<td width='410' align='center'><br><IMG

SRC=""/images/"&rsObj("Folder")&"/"&rsObj("FileName")&"""

alt="""&rsObj("Caption")&"""><br><br><b>"&rsObj("Caption")&"</b><br>"


Thanks again, I was banging my head against the wall, still have not figured out why I could only get it to display the year and not the remainder of the caption, but it is working now.

Doug
http://www.virtualautomuseum.com

felgall
08-05-2008, 09:42 PM
Thanks again, I was banging my head against the wall, still have not figured out why I could only get it to display the year and not the remainder of the caption, but it is working now.

Probably because you didn't have quotes around the alt text in the final HTML and the fifth character of the content was a space.

wizeazz101
08-05-2008, 10:35 PM
Thanks Felgall, I was writing a small subroutine, but will include it in many places in my site, I try to learn from my mistakes, but don't do enough programming to keep up on it.

Doug