SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple if() statement

    For some reason I always have problems with if() statements when I start to introduce pipes.

    I've been staring at this for a while now, but can't see where I'm going wrong. Could someone help me please?

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    if (u1==0) {
    document.write("IMG SRC='http://www.mywebsite.com/index.asp?site=4962");
    }
     
    if (u1 == 1||u1 == 2||u1 ==3||u1 ==4||u1 ==5)
    {
    document.write("IMG SRC='http://www.mywebsite.com/index.asp?site=4962");
    }
    </script>
    Thanks very much!

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script type="text/javascript">
    u1 = 2;

    if (u1==0) {
    document.write('<img src="http://www.mywebsite.com/index.asp?site=4962">');
    }

    if (u1 == 1||u1 == 2||u1 ==3||u1 ==4||u1 ==5)
    {
    document.write('<img src="http://www.mywebsite.com/index.asp?site=4962');
    }
    </script>
    You didnt have the "<" before the img, and you provided a ' for the beginning of the src but didnt end it. Try the modified one above.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •