By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,186 Members | 1,530 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,186 IT Pros & Developers. It's quick & easy.

Strange <img> tag behaviour when encapsulated in IF

P: n/a
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

Jul 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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.

"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #2

P: n/a
What's the path to the image? Is it valid as it is returned?

Ray at home

"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #3

P: n/a
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! ;-)
"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #4

P: n/a
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]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5

P: n/a
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

"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #6

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

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #7

P: n/a
Path valid. Without the if the image displays.

"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:ei**************@tk2msftngp13.phx.gbl...
What's the path to the image? Is it valid as it is returned?

Ray at home

"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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


Jul 19 '05 #8

P: n/a
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
"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> wrote in message
news:uo**************@tk2msftngp13.phx.gbl...
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.

"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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


Jul 19 '05 #9

P: n/a
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
"Gianpiero Colagiacomo" <gp@1lg.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #10

P: n/a
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]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.