Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Conflicting script

    Can someone please tell me why this script is not working?

    <script language="JavaScript">
    <!-- hide from old browsers
    var event = "V.P. debate in MO" // NAME OF EVENT GOES HERE
    var eventdate = "10/02/2008" // DATE OF EVENT GOES HERE
    var today = new Date()
    var targetDate = new Date(eventdate)
    var timeBeforeTarget = Math.floor(( targetDate.getTime()
    - today.getTime()) / 86400000)
    var msg = (timeBeforeTarget +1)
    document.write("<li style=\"list-style-type: none\">",event,": <b><a
    title=\"",eventdate,"\" id=\"date\">",msg," days</b></a></li>")
    //-->
    </script>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by rogerskf View Post
    Can someone please tell me why this script is not working?

    <script language="JavaScript">
    <!-- hide from old browsers
    var event = "V.P. debate in MO" // NAME OF EVENT GOES HERE
    var eventdate = "10/02/2008" // DATE OF EVENT GOES HERE
    var today = new Date()
    var targetDate = new Date(eventdate)
    var timeBeforeTarget = Math.floor(( targetDate.getTime()
    - today.getTime()) / 86400000)
    var msg = (timeBeforeTarget +1)
    document.write("<li style=\"list-style-type: none\">",event,": <b><a /*here's a break line*/
    title=\"",eventdate,"\" id=\"date\">",msg," days</b></a></li>")
    //-->
    </script>
    You should not break the document.write() line
    Code:
    document.write("<li style=\"list-style-type: none\">",event,": <b><a title=\"",eventdate,"\" id=\"date\">",msg," days</b></a></li>")
    And you'd better not use event as a variable. event is a javascript reserved word. Name the variable otherwise: ev, or eve...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • Users who have thanked Kor for this post:

    rogerskf (09-25-2008)


  •  

    Posting Permissions

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