Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Image in a if statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Image in a if statement

 Post Reply Post Reply
Author
WebCity View Drop Down
Groupie
Groupie
Avatar

Joined: 11 December 2003
Location: United States
Status: Offline
Points: 154
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebCity Quote  Post ReplyReply Direct Link To This Post Topic: Image in a if statement
    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?
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
WebCity View Drop Down
Groupie
Groupie
Avatar

Joined: 11 December 2003
Location: United States
Status: Offline
Points: 154
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebCity Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.