|
Counting
down to an important event. In this activity, you will create a script that
determines the number of days until the final exam project for this class
is due, on June 26th 2009.
Download the file FinalDays.html
(right mouse click and select Save File as.. from the pop-up menu), and open it in your
html editor. If the html code on the page does not look as follows,
then select this code and use it as your starting point.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FinalDays.html Insert your name here:</title>
<script language="JavaScript" type="text/JavaScript">
<!--
// USE THIS CODE BLOCK FOR SCRIPTS PUT IN THE <HEAD> SECTION
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1>Countdown to the final project due date </h1>
<h2>By (Insert Your Name Here)</h2>
<script language="JavaScript" type="text/JavaScript">
<!--
// USE THIS CODE BLOCK FOR SCRIPTS PUT IN THE <BODY> SECTION
//-->
</script>
Hope you are having a good semester!<BR>
<SCRIPT LANGUAGE="JavaScript">
<!-- Display todays date here:
// End hiding of script -->
</SCRIPT>
</body>
</html> |
Insert your name at the top of the
page where indicated.
- Enter your code in the script block
in the <BODY> section of the document. Add the JavaScript code necessary to
create a Date object for an important date in the future, such as your
birthday, anniversary or the Final Project for this course (April 27, 2004).
- Create a Date object for the current
date and time. Subtract the current date from the future date to determine the
difference in milliseconds.
- Convert those milliseconds to days
using the formula: msPerDay = 1000 * 60 * 60 * 24 (there are 1000 milliseconds in a
second, 60 seconds in a minute, 60 minutes in an hour, and 24 hours in a day).
- Write a message to the page using
document.write(), such as There
are ## days till the final project is due. using the value you
calculated and your future-date object. (To remove fractional portion of
days, use the Math.floor ( ); method.)
- Save your script page as
FinalDays.html, then upload it to your profhicks server space, and put a
hyperlink to this page on your course home page.
HINT:
In Blackboard and from the course home page see JavaScript Lessons
& Class Labs (see
JavaScript lessons and examples password
protected), then
Dates and Math in JavaScript:
Task
10B-4: Doing a little Date math, and Apply Your Knowledge 10-1: Counting down to an
important date.
Extra
Credit and HINT: You display today's date at the
bottom of the page. Refer to John Gilson's Lesson 5
JAVASCRIPT DIGITAL CLOCKS
|