Results 1 to 4 of 4

Thread: Quick JS help

  1. #1

    Thread Starter
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075

    Quick JS help

    I have a page and I am trying to display the date, however when I use any of the getDate, getHour, etc I keep getting this result:
    function getMonth() { [native code] } / function getDate() { [native code] }

    I don't understand why the functions are not working, I separated them out, but none of them work, here is my code.

    Code:
    	var d = new Date()
    	
    	document.write(d.getMonth);
    	document.write('/');
    	document.write(d.getDate);
    	document.write('/');
    	document.write(d.getFullYear);
    	document.write(' ');
    	document.write(d.getHours);
    	document.write(':');
    	document.write(d.getMinutes);
    	document.write(':'); 
    	document.write(d.getSeconds);
    Thanks!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Although I don't really know why it does this... This will fix it. Note on the Month that you need to add 1 to it because it is a 0 bound array of the months.

    Code:
    var d = new Date()
    var m = d.getMonth()
    var y = d.getFullYear()
    var h = d.getHours()
    var mn = d.getMinutes()
    var s = d.getSeconds()
    
    document.write(m+1);
    document.write('/');
    document.write(d);
    document.write('/');
    document.write(y);
    document.write(' ');
    document.write(h);
    document.write(':');
    document.write(mn);
    document.write(':'); 
    document.write(s);
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3

    Thread Starter
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Thanks, it was because I forgot the parentheses after all the get statements! Thanks anyways.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yeah if you leave out the parenthasis it returns the function's code. That is done so you can swap functions around, e.g.

    function someFunc() {
    alert('Hello');
    }
    document.forms[0].onsubmit = someFunc();

    which would make the first form's onsubmit event hander be the same as someFunc().

Posting Permissions

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



Click Here to Expand Forum to Full Width