Print Page | Close Window

Image in a if statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=27793
Printed Date: 28 March 2026 at 5:31pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Image in a if statement
Posted By: WebCity
Subject: Image in a if statement
Date Posted: 05 September 2009 at 8:57am
Below is the if statment that I am currently using.  I would like to post a image rather than text.
If Cdate <= FGdate1 then Response.Write "event info"
 
I tried the code below but it wont work.
If Cdate <= FGdate1 then <img border="0" src="images/site/games/01.png" width="169" height="51">
 
 
What am I doing wrong?



Replies:
Posted By: Scotty32
Date Posted: 05 September 2009 at 2:04pm
What you are doing is mixing HTML with ASP.

You should be doing something like this:

Green = ASP
Red = HTML

<%
     If Cdate <= FGdate1 then
%>

<img border="0" src="images/site/games/01.png" width="169" height="51">

<%
     end if
%>



How ever, if you want to do it in the style that you did above you would do it like so:

<%
     If Cdate <= FGdate1 then
            Response.Write("<img border=""0"" src=""images/site/games/01.png"" width=""169"" height="51"">")
     end if
%>


To stop the HTML's quotes from interfering with the ASP string you use double quotes to escape them as you can see in the example above.


Below is an example of HTML inside ASP but with an ASP Variable in the middle, note the colour changes.

<%
     If Cdate <= FGdate1 then
            Response.Write("
<img border=""0"" src=""images/site/games/" & FGdate1 & ".png"" width=""169"" height="51"">")
     end if
%>



Hope that helps.

PS: if you wanted the whole file name to be an ASP variable you would need 3 quotes together, one for the ASP and two for the HTML, just image the '.png' part not there and you will see what I mean.



-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: WebCity
Date Posted: 05 September 2009 at 6:30pm
Thanks Scotty,
 
That fixed my problem with my date driven image chager for events.
 
I will post my script at my first question at
http://forums.webwiz.net/date-script_topic27769.html" rel="nofollow - http://forums.webwiz.net/date-script_topic27769.html



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net