kensy11
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
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>
'Not working' means what exactly? It works for me
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i have simply taken the current year from the system date
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or else you can use the good old prompt
var currentYear = parseInt(prompt("current year"));
year= currentYear -yeardate;
var currentYear = parseInt(prompt("current year"));
year= currentYear -yeardate;
ASKER
thank you
>> but i dont know how to change the hardcoded year 2011 to be dynamic so
Sorry ;)
Sorry ;)
yeardate = parseInt (prompt("give birthday "));
alert(yeardate );
alert(yeardate );