Click to See Complete Forum and Search --> : If/Else with Photos


LiquidD
06-03-2005, 08:29 AM
Hey all,
I have this code below. It is the simple routine of if this pic show, else this pic show. This is my code that is currently working.

<% if (Recordset1.Fields.Item("Pudf_photo1").Value != "")
{ %>
<img src="../images/dsf/<%=(Recordset1.Fields.Item("Pudf_photo1").Value)%>" width="253" height="213" />
<% }
else
{%>
<img src="../images/defaultblue.jpg">
<% } %>

How can I manipulate this code to where I can uses serveral different pictures from different locations but sill use my default pic? By the way if it helps I am working with JAVASCRIPT.

Thanks!

:) Liquid :)

buntine
06-03-2005, 10:00 AM
Can you elaborate? I don't know what you mean.

wmif
06-03-2005, 11:17 AM
i would think something like this?

<%
if (Recordset1.Fields.Item("Pudf_photo1").Value != "")
{ %>
<img src="../images/dsf/<%=(Recordset1.Fields.Item("Pudf_photo1").Value)%>" width="253" height="213" />
<% }
elseif (Recordset1.Fields.Item("Pudf_photo2").Value != "")
{ %>
<img src="../images/dsf/<%=(Recordset1.Fields.Item("Pudf_photo2").Value)%>" width="253" height="213" />
<% }
elseif (Recordset1.Fields.Item("Pudf_photo3").Value != "")
{ %>
<img src="../images/dsf/<%=(Recordset1.Fields.Item("Pudf_photo3").Value)%>" width="253" height="213" />
<% }
else
{%>
<img src="../images/defaultblue.jpg">
<% } %>

hopefully javascript has elseif capability.

LiquidD
06-03-2005, 10:21 PM
Thanks for all your help. I really appreciated it.
Originally I have 3 seperate folders within my images folders. Each folder had category pics in it.
1. condos
2. homes
3. land

What I was attempting to do was create an office page that would have 1 detail page with all listings in it to include all 3 categories. The recordset would pull the image depending on that category. The problem I had was having 3 seperate folders for pics and working twice as hard to create code to pull images from 3 different folders. Hence the if elseif else problem.

In the end I combined all the images into 1 folder. I didnt want to do that since the folder contains over 1 gig of photos and uploading is a pain, but I'd rather deal with that than coding :)

* Thanks again *