Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript Problem

  • 30-03-2007 04:12AM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    This is the code in the head of the html page:
    <script type="text/javascript">
    <!--
    function date()
    {
    	var day = getDate();
    	var month = getMonth();
    	var year = getFullYear();
    	document.write(day+"/"+month+"/"+year); 
    }
    //-->
    </script>
    

    And this is the code in the body of the html page but nothing is coming up on screen:
    <script type="text/javascript">
    <!--
    	date();
    //-->
    </script>
    


Comments

  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    Looks like you forgot to create your date object :)

    var d = new Date();

    or similar ...

    getDate and so on .. are Methods ... not standalone functions ..

    hope that helps

    <script type="text/javascript">
    <!--
    function date()
    {
    	var d = new Date();
    	var day = d.getDate();
    	var month = d.getMonth();
    	var year = d.getFullYear();
    	document.write(day+"/"+month+"/"+year); 
    }
    //-->
    </script>
    
    <script type="text/javascript">
    <!--
    	date();
    //-->
    </script>
    


  • Registered Users, Registered Users 2 Posts: 568 ✭✭✭phil


    TIP #76: Use Firefox for development and at the very least use the Javascript console. Preferably use Firebug for debugging Javascript.

    Firebug - Sexual chocolate for web developers.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Venkman is a great javascript debugger for Firefox.


  • Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭Ziycon


    Nice one lads, got it sorted, i dont usually use JS but i cant use JSP,PHP or ASP on the project in doing!


Advertisement