Strange <img> tag behaviour when encapsulated in IF

  • Thread starter Gianpiero Colagiacomo
  • Start date
G

Gianpiero Colagiacomo

VBScript:

Can anyone help me figure out why the image within this IF statement shows
as a place holder rather than the image itself when the statement is
returning true?

If I remove the IF the image shows...

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
border="1
<%
End If
%>

Makes no sense to me... All I want is to show an image if there is a URL
available and nothing if not.

Cheers,

GP
 
C

Chris Barber

Syntax was incorrect.(missing dohble-quotes).

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=events.Fields.Item("picURL").Value%>" alt="URL:
<%=events.Fields.Item("picURL").Value%>" name="pic" border="1">
<%
End If
%>

Hold your mouse over the picture to see the url in the tooltip (remove if
not needed).

Chris.
 
M

Marc

Maybe the field isn't "" (an empty string) but rather Null
did you try IsNull or IsEmpty?

If that doesn't work try:

myfield = events.Fields.Item("picURL").Value & ""
If myfield <> "" Then
....

Hope that works... let us know! ;-)
 
E

Evertjan.

Gianpiero Colagiacomo wrote on 05 jul 2003 in
microsoft.public.inetserver.asp.general:
VBScript:

Can anyone help me figure out why the image within this IF statement
shows as a place holder rather than the image itself when the
statement is returning true?

If I remove the IF the image shows...

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=(events.Fields.Item("picURL").Value)%>" alt"
name="pic"
border="1
<%
End If
%>

Makes no sense to me... All I want is to show an image if there is a
URL available and nothing if not.

You are right, this makes no sense:

Serverside does not understand "(events.Fields.Item("picURL").Value)",
because asp has no events. [And why the outer (), btw]
 
T

Tammy B.

fist off, to test use might as well throw away the if then part of your
rstatement.

That leaves -

<img src="<%=(events.Fields.Item("picURL").Value)%>" alt" name="pic"
border="1

1. You have no closing >
2. Your alt is screwey - it should be alt="something" or no alt at all
3. Third, your border ="1 is wrong
4. the page is trying to interperet <img = gobledygook
 
G

Gianpiero Colagiacomo

'Events' is a recordset name. The outer () was placed there by Dreamweaver,
not me!

Evertjan. said:
Gianpiero Colagiacomo wrote on 05 jul 2003 in
microsoft.public.inetserver.asp.general:
VBScript:

Can anyone help me figure out why the image within this IF statement
shows as a place holder rather than the image itself when the
statement is returning true?

If I remove the IF the image shows...

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<img src="<%=(events.Fields.Item("picURL").Value)%>" alt"
name="pic"
border="1
<%
End If
%>

Makes no sense to me... All I want is to show an image if there is a
URL available and nothing if not.

You are right, this makes no sense:

Serverside does not understand "(events.Fields.Item("picURL").Value)",
because asp has no events. [And why the outer (), btw]
 
G

Gianpiero Colagiacomo

Yeah, sorry that was me trying to trim down the html for the newsgroup. It
actually looks like this:

<%
If (events.Fields.Item("picURL").Value) <> "" Then
%>
<TD> <div align="center">
<img src="<%=(events.Fields.Item("picURL").Value)%>"
alt="<%=(events.Fields.Item("name").Value)%>" name="pic"
border="1"></div></TD>
<%
End If
%>

Cheers,

GP
 
G

Gianpiero Colagiacomo

This is fixed. Problem was that the recordset 'events' had a cursortype of
'forward only'. I changed this to 'static' and it works perfectly.

Cheers,

GP
 
E

Evertjan.

Gianpiero Colagiacomo wrote on 05 jul 2003 in
microsoft.public.inetserver.asp.general:
'Events' is a recordset name. The outer () was placed there by
Dreamweaver, not me!


Roger. [= received as sent]
 

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
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top