Forums

This topic is locked

Image place holders - can I hide them?

Posted 13 Dec 2001 17:13:20
1
has voted
13 Dec 2001 17:13:20 Andrew Ross posted:
I have created a results page in ultradev that has the ability to display dynamic images with the records. The problem is, not all of the suppliers and services in my database will have images to display. The ones that don't have a photo end up with an image place holder instead, and this gives the page an unfinished look.

Is there any way to hide the place holders from records without an image?

Any suggestions will be greatly appreciated.

Replies

Replied 13 Dec 2001 17:47:27
13 Dec 2001 17:47:27 Owen Eastwick replied:
Yup,

Assuming that they are being dsiplayed in a table cell:

<td>
<% If RecordsetName.Fields.Item("YourImagePath".Value <> "" Then Response.Write(RecordsetName.Fields.Item("YourImagePath".Value) Else %>& nbsp;<% End If %>
</td>

Or something like:

<td>
<% If RecordsetName.Fields.Item("YourImagePath".Value <> "" Then Response.Write(RecordsetName.Fields.Item("YourImagePath".Value) Else %><img src="NoImageAvailable.gif" width="100" height="20"><% End If %>
</td>

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Edited by - oeastwick on 13 Dec 2001 17:49:26
Replied 13 Dec 2001 19:18:47
13 Dec 2001 19:18:47 Andrew Ross replied:
You're the best Owen. I will try this tonight.

Cheers,

Andrew
Replied 14 Dec 2001 04:47:22
14 Dec 2001 04:47:22 Andrew Ross replied:
Owen,

I just edited my page to:

<td rowspan="7" width="20%">
<% If rsQryDisplayFields.Fields.Item("Photo".Value <> "" Then Response.Write(rsQryDisplayFields.Fields.Item("Photo".Value)Else %> <% End If %>
</td>


Now when I try a search I get this error:

Microsoft VBScript compilation error '800a0400'

Expected statement

/canphoto_directory/results.asp, line 337

End If
^

Any suggestions?

Replied 14 Dec 2001 09:37:04
14 Dec 2001 09:37:04 Viktor Farcic replied:
Send the code around line 337.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Owen,

I just edited my page to:

&lt;td rowspan="7" width="20%"&gt;
&lt;% If rsQryDisplayFields.Fields.Item("Photo".Value &lt;&gt; "" Then Response.Write(rsQryDisplayFields.Fields.Item("Photo".Value)Else %&gt; &lt;% End If %&gt;
&lt;/td&gt;


Now when I try a search I get this error:

Microsoft VBScript compilation error '800a0400'

Expected statement

/canphoto_directory/results.asp, line 337

End If
^

Any suggestions?


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Viktor Farcic

TalkZone Manager
Replied 14 Dec 2001 11:17:46
14 Dec 2001 11:17:46 Owen Eastwick replied:
Sorry about that, try this:

&lt;%If(RecordsetName.Fields.Item("ImagePath".Value)&lt;&gt; "" Then %&gt;&lt;% = RecordsetName.Fields.Item("ImagePath".Value %&gt;&lt;% Else %&gt;& nbsp&lt;% End If %&gt;

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 15 Dec 2001 03:01:02
15 Dec 2001 03:01:02 Andrew Ross replied:
Sorry to keep bothering you Owen, but I still can't get this to work properly. Below are some of the variations of the code that I have tried.

The original UltraDev generated code. This inserts an image when there is one and a place holder when there isn't:

&lt;td rowspan="7" width="20%"&gt;
&lt;img src="images/&lt;%=(rsQryDisplayFields.Fields.Item("Photo".Value)%&gt;"&gt;
&lt;/td&gt;

The code you suggested removes the placeholder but inserts a filename instead of an image:

&lt;td rowspan="7" width="20%"&gt;
&lt;%If(rsQryDisplayFields.Fields.Item("Photo".Value)&lt;&gt; "" Then %&gt;&lt;% = rsQryDisplayFields.Fields.Item("Photo".Value %&gt;&lt;% Else %&gt; &lt;% End If %&gt;
&lt;/td&gt;

I tried combining the codes above and the results are the same as the orginal:

&lt;td rowspan="7" width="20%"&gt;
&lt;img src="images/&lt;%If(rsQryDisplayFields.Fields.Item("Photo".Value)&lt;&gt; "" Then %&gt;&lt;% = rsQryDisplayFields.Fields.Item("Photo".Value %&gt;&lt;% Else %&gt; &lt;% End If %&gt;"&gt;&lt;/td&gt;

I even tried changing ("Photo" to ("images/" because you described it as ("ImagePath", but this generated a "ADODB.Fields error '800a0cc1'"

If you have any other suggestions I will be forever grateful.

Andrew



Edited by - arossphoto on 15 Dec 2001 03:02:49
Replied 15 Dec 2001 06:40:19
15 Dec 2001 06:40:19 Andrew Ross replied:
I really don't understand VBScript yet, but through trial and error I finally got it to work. I had to take the code you provided Owen and play with the "img src" tags until I got them in right place. The code below seems to work.

&lt;td rowspan="7" width="20%"&gt;
&lt;%If(rsQryDisplayFields.Fields.Item("Photo".Value)&lt;&gt; "" Then %&gt;&lt;img src="images/&lt;% = rsQryDisplayFields.Fields.Item("Photo".Value %&gt;"&gt;&lt;% Else %&gt;&nbsp&lt;% End If %&gt;
&lt;/td&gt;

Thanks again for your help Owen. Now it's time for a big glass of Brandy<img src=../images/dmxzone/forum/icon_smile_approve.gif border=0 align=middle>

Reply to this topic