473,385 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Display pictures with if condition

Fary4u
273 100+
Hi

i'm trying to display picture using if condition

but QUESTION if there is no picture then don't bring empty picture ?

Expand|Select|Wrap|Line Numbers
  1. <html><head><title>New Page 1</title></head><body>
  2. <%
  3.  strImage = "1.jpg"
  4. strImage2 = "2.jpg"
  5. strImage3 = "3.jpg"
  6. %>
  7.     <img src="img/<%= strImage %>"><br>
  8.     <% If strImage2 = "" Then response.wite "" else if %>
  9.     <img src="img/<%= strImage2 %>"><br>
  10.     <% If strImage3 = "" Then response.wite "" else %>
  11.     <img src="img/<%= strImage3 %>">
  12.     <% end if %>
  13. </body></html>
  14.  
any body know how's this gonna work coz it's seem not working ?
Nov 8 '07 #1
5 2216
omerbutt
638 512MB
Hi

i'm trying to display picture using if condition

but QUESTION if there is no picture then don't bring empty picture ?

Expand|Select|Wrap|Line Numbers
  1. <html><head><title>New Page 1</title></head><body>
  2. <%
  3.  strImage = "1.jpg"
  4. strImage2 = "2.jpg"
  5. strImage3 = "3.jpg"
  6. %>
  7.     <img src="img/<%= strImage %>"><br>
  8.     <% If strImage2 = "" Then response.wite "" else if %>
  9.     <img src="img/<%= strImage2 %>"><br>
  10.     <% If strImage3 = "" Then response.wite "" else %>
  11.     <img src="img/<%= strImage3 %>">
  12.     <% end if %>
  13. </body></html>
  14.  
any body know how's this gonna work coz it's seem not working ?
hey where have u placed ur pictures which u r trying to show have u first saved them to any database through a form and then display it through quering the database by Select query.
Nov 23 '07 #2
Fary4u
273 100+
Yep i've done every thing which you need to display picture
also my code is working fine

regards
Fary
Dec 3 '07 #3
Nicodemas
164 Expert 100+
Hi

i'm trying to display picture using if condition

but QUESTION if there is no picture then don't bring empty picture ?

Expand|Select|Wrap|Line Numbers
  1. <html><head><title>New Page 1</title></head><body>
  2. <%
  3.  strImage = "1.jpg"
  4. strImage2 = "2.jpg"
  5. strImage3 = "3.jpg"
  6. %>
  7.     <img src="img/<%= strImage %>"><br>
  8.     <% If strImage2 = "" Then response.wite "" else if %>
  9.     <img src="img/<%= strImage2 %>"><br>
  10.     <% If strImage3 = "" Then response.wite "" else %>
  11.     <img src="img/<%= strImage3 %>">
  12.     <% end if %>
  13. </body></html>
  14.  
any body know how's this gonna work coz it's seem not working ?
You should simplify your code, it will work better and appear cleaner this way:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. strImage = "1.jpg"
  3. strImage2 = "2.jpg"
  4. strImage3 = "3.jpg"
  5.  
  6. if strImage <> "" then response.write "<img src="""& strImage &""" /><br />"
  7. if strImage2 <> "" then response.write "<img src="""& strImage2 &""" /><br />"
  8. if strImage3 <> "" then response.write "<img src="""& strImage3 &""" /><br />"
  9. %>
Dec 7 '07 #4
improvcornartist
303 Expert 100+
If I understand your question correctly, you may be able to change your image link to
Expand|Select|Wrap|Line Numbers
  1. <img src="img/<%= strImage %>" alt="">
to keep it from displaying an empty picture. Also, if you have many images, you should be able to loop over them instead of writing an if..then statement for each one.
Dec 7 '07 #5
Nicodemas
164 Expert 100+
If I understand your question correctly, you may be able to change your image link to
Expand|Select|Wrap|Line Numbers
  1. <img src="img/<%= strImage %>" alt="">
to keep it from displaying an empty picture. Also, if you have many images, you should be able to loop over them instead of writing an if..then statement for each one.
Sir, I'm afraid that still would create an "empty" (read: broken) image if strImage is [empty|empty string].

The solution I posted will prevent it from happening.
Dec 7 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chumley the Walrus | last post by:
IN my code behind .vb page for a delete records script (this also does a deletion confirmation with a javascript popup, this gets called on my front .aspx page with the datagrid), I'm not sure if...
3
by: RAllsopp | last post by:
I have a client who would like to have several pictures associated with one system. I have read about storing only the pathname to save OLE overhead and have set-up a form for my client to...
1
by: bborden | last post by:
Novice Access programmer here. I would like to display an image using the Toolbox Image object by calling the images file name using: =fPictureFiles(!!,1) in the Picture control. Below...
12
by: Wadim Grasza | last post by:
I want to store and display (on a form or a report) multiple pictures per record in an access database. The pictures are not stored within the database. They are stored as files and the database...
0
by: George Race | last post by:
I am trying to display pictures in either ReportViewer or Crystal Reports, using VB 2005. I have the path to pictures in a Form text box that is linked to the database containing the full path to...
10
by: thh108688 | last post by:
Hi all, I have got a question here perhaps someone can provide me some good information or suggestion. In the Access Form I have created 2 combo box one is Activity combo box, the other is...
0
by: Ian | last post by:
I have an Access 2000 database in which I display many pictures on reports, the pictures are not embedded, the database just stores the path to where the pictures are stored. When I select Gifs,...
1
by: Ian | last post by:
I have an Access 2000 database in which I display many pictures on reports, the pictures are not embedded, the database just stores the path to where the pictures are stored. When I select Gifs,...
46
by: OldBirdman | last post by:
What a mess this question is. I have spent 2 weeks trying to make it concise and clear, and I can't. I do not have the vocabulary for the question. I cannot even TITLE it correctly. Here is my...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.