1.

Solve : Why doesn't this very simplistic function work??

Answer»

This code displays the button then nothing happens when I click on it. Can someone please tell me why?  Thank you in advance for your reply.
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml">


   Displaying Times and Dates

 
     
     
   Function getData()  {
   
    var   now = ""
     var   localtime1 = ""
     var   utctime1 = ""
     var    myButton = document.getElementById("myButton");
   
      now = new Date();

      localtime1 = now.Tostring();
      utctime1 = now.toGMTString();
      alert("Local Time: '
      + Localtime1 + '
");
      alert("UTC Time: " + utctime1);
    }     

   Function test() {
   
   alert("Testing to see if this executed");

   }





Current Date and Time






You are missing SEMICOLONS from these lines:
Code: [Select] var   now = ""
     var   localtime1 = ""
     var   utctime1 = ""
That said, there are other errors after that caused by strange capitalisation on things, Javascript is case sensitive so you need to take care to use the correct case.  Javascript uses "lowerCamelCase" so the first letter is always lowercase and the first letter of each word after this is a capital, you should ADHERE to this in your program to keep it neat.   You should also take care with your indentation as it's currently pretty messy and heard to read.  Finally, you no longer need the "language" attribute in the script tag as that is out of date, the 'type="text/javascript"' is all you should need nowadays.Just a little language note here... 'simplistic' is used about points raised in DEBATE or argument and means "MISLEADINGLY over-simplified' - I think the word you need is 'simple'.



Discussion

No Comment Found