This first tutorial is a very simple one, we are going to make a button and have it check the time and display it on the screen.

<!DOCTYPE html>
<html>
<head>
<script language="javascript" type="text/javascript">
function displayDate()
{
document.getElementById("date").innerHTML=Date();
}
</script>
</head>
<body>

<h1>Ozzu JavaScript</h1>
<p id="date">Click here to check the date from your computer.</p>

<button type="button" onclick="displayDate()">Display Date</button>

</body>
</html> 

Making note about the full stops

document.getElementById("date").innerHTML=Date();
The full stops between each element function is a + variable so this line would mean document+getElementById("date")+innerHTML=Date();

lines 1-3 General HTML header
line 4 Script tag where we have set the JavaScript language and text type JavaScript
line 5 First Function with displayDate()
line 6 { open the function
line 7 Document = page
getElementById("date") = requesting information using a variable
innerHTML=Date() = ID for HTML to run the function
line 8 } Close off the function | this section finished
line 9 closing of script
line 10 closing of head
line 11 Body Start
line 12 header1 title
line 13 p tag using id(date) requested the script above via the "date"
line 14 button tag made a button | onclick "displayDate()" is going to load the function from the script when clicked.
line 15-16 closing HTML

I have taken a simple script in Javascript and broken it down line by line to give starting script writers a better understanding of what they are looking at but if you can understand how a button works and works with the script on how to load a function then it is a good start.

Also i am more then happy to work on more complex tutorials if someone requests.

This page was published on It was last revised on

0

0 Comments

  • Votes
  • Oldest
  • Latest

User

Community

Market

Help Center

Legal

Company

Social Media

\n\n\n\n

Ozzu JavaScript

\n

Click here to check the date from your computer.

\n\n\n\n\n \n```\n\n**Making note about the full stops**\n\n```\ndocument.getElementById(\"date\").innerHTML=Date();\nThe full stops between each element function is a + variable so this line would mean document+getElementById(\"date\")+innerHTML=Date();\n```\n\n**lines 1-3** General HTML header\n**line 4 **Script tag where we have set the JavaScript language and text type JavaScript\n**line 5** First Function with displayDate()\n**line 6** { open the function\n**line 7** Document = page\ngetElementById(\"date\") = requesting information using a variable\ninnerHTML=Date() = ID for HTML to run the function\n**line 8** } Close off the function | this section finished\n**line 9** closing of script\n**line 10** closing of head\n**line 11** Body Start\n**line 12** header1 title\n**line 13** p tag using id(date) requested the script above via the \"date\"\n**line 14** button tag made a button | onclick \"displayDate()\" is going to load the function from the script when clicked.\n**line 15-16** closing HTML\n\nI have taken a simple script in Javascript and broken it down line by line to give starting script writers a better understanding of what they are looking at but if you can understand how a button works and works with the script on how to load a function then it is a good start.\n\nAlso i am more then happy to work on more complex tutorials if someone requests.","url":"https://www.ozzu.com/wiki/595398/simple-js-date-button-explained","datePublished":"2012-09-15T18:12:53+00:00","dateModified":"2012-09-16T01:12:53+00:00","author":{"@type":"Person","name":"Zealous"},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":"https://schema.org/LikeAction","userInteractionCount":0},{"@type":"InteractionCounter","interactionType":"https://schema.org/ViewAction","userInteractionCount":4386}],"comment":[]}