SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast vso's Avatar
    Join Date
    Oct 2003
    Location
    VA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    html valid java script

    I want my page to validate.

    http://vitaminshoppeonline.com is the page in question.

    The script is controlling the product of the day.

    Here is the script:

    <SCRIPT type="text/javascript" LANGUAGE="JavaScript">
    <!-- Begin
    today = new Date();
    day = today.getDay();
    arday = new Array("images/sunday.gif", "images/monday.gif", "images/tuesday.gif",
    "images/wednesday.gif", "images/thursday.gif", "images/friday.gif", "images/saturday.gif");
    arURL = new Array("Sunday.shtml", "Monday.shtml", "Tuesday.shtml",
    "Wednesday.shtml", "Thursday.shtml", "Friday.shtml", "Saturday.shtml");
    document.write("<a href='" + arURL[day] + "'><img src='" + arday[day] + "' border='0'></a>");
    // End -->
    </script>

    Because of the tiny little end tag </a>, the wc3 validator is telling me the tag was closed when it was never opened. Yet, in the last document write, you can plainly see it is opened.

    What do I need to do to get this script to validate?

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make the scripting external
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Enthusiast vso's Avatar
    Join Date
    Oct 2003
    Location
    VA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beetle
    Make the scripting external
    Beetle, by making the Java Script external, are you suggesting a *.js file, that is placed in the header?

    I sort of understand that, but if I take all of the script and stick it in a jar file, then what do I put in its place in the body of the source code where the script use to be.

    http://vitaminshoppeonline.com is where you can see the script in action.

    I spose the jar file would contain JUST The script, like so:

    today = new Date();
    day = today.getDay();
    arday = new Array("images/sunday.gif", "images/monday.gif", "images/tuesday.gif",
    "images/wednesday.gif", "images/thursday.gif", "images/friday.gif", "images/saturday.gif");

    arURL = new Array("Sunday.shtml", "Monday.shtml", "Tuesday.shtml",
    "Wednesday.shtml", "Thursday.shtml", "Friday.shtml", "Saturday.shtml");

    document.write("<a href='" + arURL[day] + "'><img src='" + arday[day] + "' border='0'></a>");

    Then I would place

    <script type="text/javascript" language="javascript" src="daily.js"></script>

    in the header of the page.

    But then what code would go into the main body where the above script use to be?

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's exactly right -- only difference is that the linked script can go in the body -- doesn't have to be the head.

    Also, FYI, a jar file is a Java Archive, and isn't a Javascript filetype.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Enthusiast vso's Avatar
    Join Date
    Oct 2003
    Location
    VA
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Got It

    [QUOTE='beetle']That's exactly right -- only difference is that the linked script can go in the body -- doesn't have to be the head.

    I see what you mean.

    I forgot to upload the js file. LOL, and when it didnt work I thought I was doomed. Uploaded the file and it worked just fine!

    Thanks Mate.


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
  •