Link to home
Start Free TrialLog in
Avatar of kensy11
kensy11Flag for Belgium

asked on

dynamic java

hello,

i have this java code it ask for the birthday and gives how old your are, but i want the year to be dynamic so instead of hardcoding the year 2011,  the java shuld ask what year are we now and .....

i have tried everything it's not working

here is my code


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>3</title>
	</head>
	<body>
		
		<script type="text/javascript">
		name = prompt("your last name");
		
		document.write( "Welkom " + name );
        </script>
		
		<script type="text/javascript">
		fname = prompt("your first name");
		yeardate = parseInt (prompt("give birthday "));
		year= 2011-yeardate
		alert(fname + " , you are " + year + " years!"  );
		
		
		</script>

	</body>
	

</html>

Open in new window

Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

'Not working' means what exactly? It works for me
Avatar of kensy11

ASKER

this code works but i dont know how to change the hardcoded year 2011 to be dynamic so  the java shuld ask what year are we now and .....
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i have simply taken the current year from the system date
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or else you can use the good old prompt

var currentYear = parseInt(prompt("current year"));
year= currentYear -yeardate;
Avatar of kensy11

ASKER

thank you
>> but i dont know how to change the hardcoded year 2011 to be dynamic so  

Sorry ;)
  yeardate = parseInt (prompt("give birthday "));
alert(yeardate );