Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Nathon Jones #1
IF, END IF and ELSE? How do I add an ELSE?
Hi,
I have a dynamic field in the database with an image reference. I have this
set up as a Hide If Empty kind of idea, as follows:
<%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
<img src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> "
border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
<%End IF%>
What do I need to add to this code in order to display an image, should the
"photograph" field be empty?
Thanks.
Nath.
Nathon Jones Guest
-
Joe Makowiec #2
Re: IF, END IF and ELSE? How do I add an ELSE?
On 04 Mar 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
<%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>> Hi,
>
> I have a dynamic field in the database with an image reference. I
> have this set up as a Hide If Empty kind of idea, as follows:
>
> <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
> <img
> src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%>
> " border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
> <%End IF%>
>
> What do I need to add to this code in order to display an image,
> should the "photograph" field be empty?
<img src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> " border="1"
alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
<% Else %>
<img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
<%End IF%>
where noimage.jpg is either a blank of the appropriate size, or
something saying 'there's no dog here'.
--
Joe Makowiec
[url]http://makowiec.net/[/url]
Email: [url]http://makowiec.net/email.php[/url]
Joe Makowiec Guest
-
Singularity.co.uk #3
Re: IF, END IF and ELSE? How do I add an ELSE?
You should also check for a NULL value from the database as follows:
<%
Dim Photo
Photo = (rsDogInfo.Fields.Item("photograph").Value)
IF NOT ISNULL(Photo) And Photo <> "" Then%>
<img src="dog-photographs/<%=Photo%>" border="1"
alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
<%
Else
%>
<img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
<%
End IF
%>
Brendan
"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns960F40A4C5526makowiecatnycapdotrE@216.104. 212.96...src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> "> On 04 Mar 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
>>> > Hi,
> >
> > I have a dynamic field in the database with an image reference. I
> > have this set up as a Hide If Empty kind of idea, as follows:
> >
> > <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
> > <img
> > src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%>
> > " border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
> > <%End IF%>
> >
> > What do I need to add to this code in order to display an image,
> > should the "photograph" field be empty?
> <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
> <img
border="1"> alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
> <% Else %>
> <img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
> <%End IF%>
>
> where noimage.jpg is either a blank of the appropriate size, or
> something saying 'there's no dog here'.
>
> --
> Joe Makowiec
> [url]http://makowiec.net/[/url]
> Email: [url]http://makowiec.net/email.php[/url]
Singularity.co.uk Guest



Reply With Quote

