Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Problem

Options
  • 30-03-2007 5:12am
    #1
    Registered Users Posts: 1,987 ✭✭✭


    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 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 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 Posts: 7,468 ✭✭✭Evil Phil


    Venkman is a great javascript debugger for Firefox.


  • Registered Users Posts: 1,987 ✭✭✭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