Forums
This topic is locked
Conditional display of dynamic images
Posted 25 Mar 2003 16:09:50
1
has voted
25 Mar 2003 16:09:50 Jay Atwood posted:
I am trying to create a display records page with a pseudo-thumbnail image whose path is stored in a database and attach an anchor to that dynamic image in order to make the image open in a new window to show the full size image.I'm using Pure ASP Upload and the path to the image is saved in two distinct fields (photo and largephoto).
The problem comes when a user does not upload a photograph. I would like a default image to be displayed. I've searched through these forums and found several answers and tried them all but none of them give me exactly what I need.
The code I have now will display the default image if the field is null, but it won't display the real image if the field is populated with the correct path to the image.
I believe this has something to do with my coding in the first part of each conditional statement. It's returning code with no value in the HREF and SRC tags when there IS a value in the table of the DB (I'm using Access by the way).
I haven't worked with conditional ASP statements so I'm turning to this forum for help.
I've pasted the code from the section of the page below.
I know this is a recurring theme in the Pure ASP Upload forum but the answer seems to evade us all.
CODE_______________
<td align="right" valign="top" class="allstyle">Photo:<br>
<span class="allstyle">
<% if (rsAllView.Fields.Item("photo".Value) <> "" then %><a href="<%= rsAllView.Fields.Item("photo".Value %>" target="_blank"><% else ' no image %><a href="photos/bamboo2.jpg" target="_blank"><% end if ' image check %>
<% if (rsAllView.Fields.Item("largephoto".Value) <> "" then %><IMG SRC= "<%=rsAllView.Fields.Item("largephoto".Value%>" alt="Click to enlarge" name="photo" width="100" height="75" border="0"><% else ' no image %><IMG SRC="photos/bamboo2.jpg" alt="Click to enlarge" name="photo" width="100" height="75" border="0"><% end if ' image check %> </a><br>
Click image to enlarge <br></span></td>
Replies
Replied 26 Mar 2003 02:55:55
26 Mar 2003 02:55:55 Phil Shevlin replied:
It seems like you're checking two different fields in your statement. Your opening <a> is conditionally checking "photo" but your closing </a> is checking "largerPhoto"
Its tough to do this without seeing the page but -- assuming "photo" is the thumbnail and "largerPhoto" is the (eh..) larger photo then try this:
<pre id=code><font face=courier size=2 id=code>
<% if (rsAllView.Fields.Item("largephoto".Value) <> "" then %>
<a href="<%= rsAllView.Fields.Item("largephoto".Value %>" target="_blank"><IMG SRC= "<%=rsAllView.Fields.Item("photo".Value%>" alt="Click to enlarge" name="photo" width="100" height="75" border="0"></a>
<% else %>
<a href="photos/bamboo2.jpg" target="_blank"><IMG SRC="photos/bamboo2.jpg" alt="Click to enlarge" name="photo" width="100" height="75" border="0"></a>
<% end if ' image check %>
</font id=code></pre id=code>
The other point to consider is you are linking to a photo not an HTML page. This might play havoc with older browsers.
Edited by - wdglide on 26 Mar 2003 02:58:53
Its tough to do this without seeing the page but -- assuming "photo" is the thumbnail and "largerPhoto" is the (eh..) larger photo then try this:
<pre id=code><font face=courier size=2 id=code>
<% if (rsAllView.Fields.Item("largephoto".Value) <> "" then %>
<a href="<%= rsAllView.Fields.Item("largephoto".Value %>" target="_blank"><IMG SRC= "<%=rsAllView.Fields.Item("photo".Value%>" alt="Click to enlarge" name="photo" width="100" height="75" border="0"></a>
<% else %>
<a href="photos/bamboo2.jpg" target="_blank"><IMG SRC="photos/bamboo2.jpg" alt="Click to enlarge" name="photo" width="100" height="75" border="0"></a>
<% end if ' image check %>
</font id=code></pre id=code>
The other point to consider is you are linking to a photo not an HTML page. This might play havoc with older browsers.
Edited by - wdglide on 26 Mar 2003 02:58:53
Replied 29 Mar 2003 02:39:15
29 Mar 2003 02:39:15 Robbie Laliberte replied:
I have found that using the isNull feature in Access works very well.
<%if NOT isNUll (photo)%> show image
<% else %>
show default image
<% end if %>
Don't ask me why I went with NOT isNull.. for whatever reason that is what I tried first and it worked. I am not using it to link to an image, but just to display or not display an image.
Hope this helps,
Chariot
<%if NOT isNUll (photo)%> show image
<% else %>
show default image
<% end if %>
Don't ask me why I went with NOT isNull.. for whatever reason that is what I tried first and it worked. I am not using it to link to an image, but just to display or not display an image.
Hope this helps,
Chariot