<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Age Calculator</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

<body>

<h1>

Age Calculator</h1>

<script type="text/javascript">

/* <![CDATA[ */

var startyear = "1950";

var endyear = "2010";

var dat = new Date();

var curday = dat.getDate();

var curmon = dat.getMonth() + 1;

var curyear = dat.getFullYear();

// This function DaysInMonth determines how many days in the month

function DaysInMonth(Y, M) {

with (new Date(Y, M, 1, 12)) {

setDate(0);

return getDate();

}

}

// This function datediff calculates the difference between the date1 and date2 entered into the function.

function datediff(date1, date2) {

var y1 = date1.getFullYear(), m1 = date1.getMonth(), d1 = date1.getDate(),

y2 = date2.getFullYear(), m2 = date2.getMonth(), d2 = date2.getDate();

if (d1 < d2) {

m1--;

d1 += DaysInMonth(y2, m2);

}

if (m1 < m2) {

y1--;

m1 += 12;

}

return [y1 - y2, m1 - m2, d1 - d2];

}

// This function calage first checks to see if the selections are blank or not then submits the entered data

// This is where you must enter lines of code after the 3 variables are declared!

function calage() {

var calday = document.forms[0].date.options[document.forms[0].date.selectedIndex].value;

var calmon = document.forms[0].month.options[document.forms[0].month.selectedIndex].value;

var calyear = document.forms[0].year.options[document.forms[0].year.selectedIndex].value;

YOUR CODE HERE!

}

/* ]]> */

</script>

<form action="">

<p>

<script type="text/javascript">

// These lines of code allow for the user to select the date drop down menu

/* <![CDATA[ */

document.write("Day <select name='date' size='1'>");

for (var j = 1; j < 32; j++)

document.write("<option value=" + j + ">" + j + "<" + "/option" + ">");

document.write("<" + "/select" + ">");

/* ]]> */

</script>

<script type="text/javascript">

// These lines of code allow for the user to select the month drop down menu

/* <![CDATA[ */

document.write("Month <select name='month' size='1'>");

for (var i = 1; i < 13; i++)

document.write("<" + "option value=" + i + ">" + i + "<" + "/option" + ">");

document.write("<" + "/select" + ">");

/* ]]> */

</script>

<script type="text/javascript">

// These lines of code allow for the user to select the year drop down menu

/* <![CDATA[ */

document.write("Year <select name='year' size='1'>");

for (var k = startyear; k <= endyear; k++)

document.write("<option value=" + k + ">" + k + "<" + "/option" + ">");

document.write("<" + "/select" + ">");

/* ]]> */

</script>

<input name="start" onclick="calage()" value="Calculate" type="button" /<br />

Result

<input name="age" size="40" value="Result" /</p>

<p>

You have been living for:</p>

<p>

Months:

<input name="months" size="30" /<br />

Days:

<input name="day" size="30" /<br />

</p>

</form>

</body>

</html>