FireGeek21
Technical User
Hi,
I have been working with HTML for a while but have done nothing fancy (yet). Starting to incorporate some javascript into my HTML. My first task is to display a person's age based on the birthdate entered into an input box. I can't seem to get the age to show next to the input box. Here is the code I have been working with. Thanks for the help!!!
FireGeek
(currently using Crystal Reports XI with Lawson 9.01)
I have been working with HTML for a while but have done nothing fancy (yet). Starting to incorporate some javascript into my HTML. My first task is to display a person's age based on the birthdate entered into an input box. I can't seem to get the age to show next to the input box. Here is the code I have been working with. Thanks for the help!!!
HTML:
<html>
<head>
<title>Display Age Calculation</title>
<script type="text/javascript">
function calcAge(birthMonth, birthDay, birthYear)
{
todayDate = new Date();
todayYear = todayDate.getFullYear();
todayMonth = todayDate.getMonth();
todayDay = todayDate.getDate();
age = todayYear - birthYear;
if (todayMonth < birthMonth - 1)
{
age;
}
if (birthMonth - 1 == todayMonth && todayDay < birthDay)
{
age;
}
return age;
}
</script>
</head>
<body>
<form>
<input type="text" name="birthdate" onblur="calcAge()"><div id="agecalc">Your Age: </div>
</form>
</body>
</html>
FireGeek
(currently using Crystal Reports XI with Lawson 9.01)