Results 1 to 6 of 6

Thread: JavaScript Help

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    1,024

    JavaScript Help

    I'm sure someone here must know some javascript, and I am hoping to get some help making something in it. Can someone possibly write me a code? Here is what I want.

    I need a script that goes into the <head> , and then allows me to place the date anywhere in the page with another insertable thingy. I am not to up on javascript so try and stay with me... I need it to place JUST the date.

    Like,

    <head>
    <script type=javascript
    (blabda bldab
    </script>

    <body>

    Today's date is <script that inserts date>

    then I have a calendar already built below this.


    BTW, this is ALL for my father, who runs a website for Special Olympics... for free... So you might be able to guess he doesn't work too teribly hard on it, and considers himself to old to learn a bunch of new stuff. If this was all for myself I would most certainly go and learn it myself, but I do not want to take the time to learn JS just for this. Thanks for any help...
    [H]ard|OCP <--Best hardware/gaming news out there--|
    pwned.nl <--Gamers will love this one --|
    Light a man a fire and you\'ll keep him warm for a day, Light a man ON fire and you\'ll keep him warm the rest of his life.

  2. #2
    Senior Member
    Join Date
    Dec 2003
    Location
    LA, CA
    Posts
    292
    Code:
    date=new Date();
    day=date.getDate();
    year=date.getYear();
    if (year &lt; 2000) year=year+1900;
    TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;
    TodaysDate would read Friday 9 July 2004 (as of this posting )
    A mind full of questions has no room for answers

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Posts
    1,024
    So what would I put where? Sorry, I'm not too good with JS... I need to go learn more but anyways.
    [H]ard|OCP <--Best hardware/gaming news out there--|
    pwned.nl <--Gamers will love this one --|
    Light a man a fire and you\'ll keep him warm for a day, Light a man ON fire and you\'ll keep him warm the rest of his life.

  4. #4
    Junior Member
    Join Date
    Mar 2004
    Posts
    14
    There's a variety of scripts out there you could use. Here's a different one. You could place this in the head of the document, although I usually just place my site name, info, trackin info in the head? Either way..

    &lt;SCRIPT&gt;

    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();

    if (intHours == 0) {

    hours = "12:";

    ap = "It's midnight";
    } else if (intHours &lt; 12) {
    hours = intHours+":";
    ap = " AM";
    } else if (intHours == 12) {
    hours = "12:";
    ap = "It's noon";
    } else {
    intHours = intHours - 12
    hours = intHours + ":";
    ap = " PM";
    }
    if (intMinutes &lt; 10) {
    minutes = "0"+intMinutes+":";
    } else {
    minutes = intMinutes+":";
    }
    if (intSeconds &lt; 10) {
    seconds = "0"+intSeconds+" ";
    } else {
    seconds = intSeconds+" ";
    }
    timeString = hours+minutes+seconds+ap;
    Clock.innerHTML = timeString;
    window.setTimeout("tick();", 100);
    }
    window.onload = tick;
    &lt;/SCRIPT&gt;
    &lt;DIV id=Clock style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt"&gt; &lt;/DIV&gt;

  5. #5
    Senior Member
    Join Date
    Jun 2003
    Posts
    219
    If you want you can check out http://www.javascripts.com

    you can get the readymade scripts for free there!!
    Now is the moment, or NEVER!!!

  6. #6
    Junior Member
    Join Date
    Dec 2002
    Posts
    27
    hmm i have some way to do that. u can put javascript function in to another file like "script.js". and then u call it from your page like this

    &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script language="JavaScript" src="script.js"&gt;
    &lt;/script&gt;
    &lt;/head&gt;

    and example to call that function like this.

    &lt;body topmargin="0" leftmargin="0" onLoad="myTime()"&gt;

    the function myTime() are:

    function myTime() {
    var today = new Date()
    var hours = today.getHours()
    var minutes = today.getMinutes()
    var seconds = today.getSeconds()
    var suffix="AM"

    if (hours &gt;= 12) {
    suffix="PM"
    }

    if (hours &gt;= 13) {
    hours-=12
    } else if (hours == 0) {
    hours = 12
    }

    if (minutes &lt; 10) {
    minutes = "0" + minutes
    }

    if (seconds &lt; 10) {
    seconds = "0" + seconds
    }

    var time = hours + ":" + minutes + ":" + seconds + " " + suffix

    parent.header.time.value = time

    timer = window.setTimeout("myTime()", 1000)
    }

    or u can exactly include the script itself to your html

    &lt;SCRIPT Language=JavaScript&gt;
    &lt;!--
    var mon = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

    var d = new Date();
    var date = d.getDate();
    var month = d.getMonth();
    var year = d.getYear();
    if (navigator.appName == 'Netscape') {
    year = d.getYear() + 1900;
    }
    document.write(date + " " + mon[month] + " " + year);
    --&gt;
    &lt;/SCRIPT&gt;
    Lord Xavier,
    Cyberdelia Technologies,
    (Wholly owned by Cyberdelia Group).

Posting Permissions

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