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

Thread: Help to modify

  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    UK
    Posts
    302
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Question Help to modify

    Hi,


    Can someone please help me modify this script to also display the time and date.


    Thanks in advance.




    <HEAD>

    <SCRIPT LANGUAGE="JavaScript">


    <!-- Begin
    var expDays = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    var ShowCount = 0;
    var SwapColour;
    function ListToDoItems() {
    var NumToDoItems = GetCookie('PT_NumToDoList');
    var i;
    var ToDoItem;
    if (NumToDoItems == null) {
    NumToDoItems = 0;
    }
    ShowCount = 0; SwapColour = 0;
    for (i=1; i <= NumToDoItems; i++) {
    ToDoItem = GetCookie('PT_ToDoItem'+i);
    if (ToDoItem != null) {
    PrintItem(ToDoItem, i);
    }
    }
    }
    function DeleteItem(Count) {
    DeleteCookie('PT_ToDoItem'+Count);
    window.location = window.location;
    }
    function PrintItem (ToDoItem, Count) {
    var color = "";
    SwapColour = 1 - SwapColour;
    if (SwapColour=1) {color = "bgcolor='#c0c0c0'"} ;
    ShowCount++;
    document.write("<tr " + color + ">");
    document.write("<td width=10% align=center valign=top><small><b>"+ShowCount);
    document.write("<td width=75% align=left ><small>"+ToDoItem);
    document.write("<td width=15% align=center><small>"+"<a href='javascripteleteItem(" + Count + ")'>Delete</a>");
    }
    function AddItem() {
    var NumToDoItems = GetCookie('PT_NumToDoList');
    var i;
    var ToDoItem;
    if (NumToDoItems == null) {
    NumToDoItems = 0;
    }
    ToDoItem = prompt("Enter new item");
    if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
    NumToDoItems++;
    SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
    SetCookie('PT_NumToDoList',NumToDoItems, exp);
    window.location = window.location;
    }
    }
    function set() {
    VisitorName = prompt("Who are you?");
    SetCookie ('VisitorName', VisitorName, exp);
    SetCookie ('WWHCount', 0, exp);
    SetCookie ('WWhenH', 0, exp);
    }
    function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
    return null;
    }
    function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
    }
    function DeleteCookie (name) {
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
    }
    // End -->
    </script>

    </HEAD>

    <!-- STEP TWO: Copy this code into the BODY of your HTML document -->

    <BODY>

    <b><big><font color="#000080">Caller Log.</font></big></b><center>
    <hr><br>
    <table width=100%>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    ListToDoItems();
    // End -->
    </SCRIPT>
    </table>
    <br><hr>
    <center>
    <a href="javascript:AddItem()">Add Item</a>
    </center>

    </center>
    Kind regards,
    Mike Hughes

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script language="JavaScript"> 
    <!-- 
            s_date = new Date(); 
            var weekDay = ""; 
            selectMonth = new Array(12); 
                   selectMonth[0] = "January"; 
                   selectMonth[1] = "February"; 
                   selectMonth[2] = "March"; 
                   selectMonth[3] = "April"; 
                   selectMonth[4] = "May"; 
                   selectMonth[5] = "June"; 
                   selectMonth[6] = "July"; 
                   selectMonth[7] = "August"; 
                   selectMonth[8] = "September"; 
                   selectMonth[9] = "October"; 
                   selectMonth[10] = "November"; 
                   selectMonth[11] = "December"; 
            if(s_date.getDay() == 1){ 
                   weekDay = "Monday"; 
            } 
            if(s_date.getDay() == 2){ 
                   weekDay = "Tuesday"; 
            } 
            if(s_date.getDay() == 3){ 
                   weekDay = "Wednesday"; 
            } 
            if(s_date.getDay() == 4){ 
                   weekDay = "Thursday"; 
            } 
            if(s_date.getDay() == 5){ 
                   weekDay = "Friday"; 
            } 
            if(s_date.getDay() == 6){ 
                   weekDay = "Saturday"; 
            } 
            if(s_date.getDay() == 7){ 
                   weekDay = "Sunday"; 
            } 
            if(s_date.getDay() == 0){ 
                   weekDay = "Sunday"; 
            } 
    
            var setYear = s_date.getYear(); 
    var BName = navigator.appName; 
    if(BName == "Netscape"){ 
            var setYear = s_date.getYear() + 1900; 
    } 
    document.write("Today is: " + weekDay + ", " + selectMonth[s_date.getMonth()] + " " + 
    s_date.getDate() + ", " + setYear); 
    // --> 
    </script>
            
    <script language = "JavaScript"> 
    function tick() { 
    var hours, minutes, seconds, ap; 
    var intHours, intMinutes, intSeconds; 
    var today; 
    today = new Date(); 
    intHours = today.getHours(); 
    intMinutes = today.getMinutes(); 
    intSeconds = today.getSeconds(); 
    switch(intHours){ 
           case 0: 
               intHours = 12; 
               hours = intHours+":"; 
               ap = "A.M."; 
               break; 
           case 12: 
               hours = intHours+":"; 
               ap = "P.M."; 
               break; 
           case 24: 
               intHours = 12; 
               hours = intHours + ":"; 
               ap = "A.M."; 
               break; 
           default:     
               if (intHours > 12) 
               { 
                 intHours = intHours - 12; 
                 hours = intHours + ":"; 
                 ap = "P.M."; 
                 break; 
               } 
               if(intHours < 12) 
               { 
                 hours = intHours + ":"; 
                 ap = "A.M."; 
               } 
        }        
    if (intMinutes < 10) { 
         minutes = "0"+intMinutes+":"; 
    } else { 
         minutes = intMinutes+":"; 
    } 
    if (intSeconds < 10) { 
         seconds = "0"+intSeconds+" "; 
    } else { 
         seconds = intSeconds+" "; 
    } 
    timeString = hours+minutes+seconds+ap; 
    Clock.innerHTML = timeString; 
    window.setTimeout("tick();", 100); 
    } 
    window.onload = tick; 
    </script>
    <div id=Clock align=left class="adres">&nbsp;</div>


  •  

    Posting Permissions

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