Bojangles69
04-26-2006, 03:17 AM
ive managed to keep a B in this class only because the test are multiple choice, but when it comes to writing code i can understand it after its wrote but have a hard time with logic.(plus im right brain dominant) but this is what i was given as a template, that needs to be modified. The goal is to prompt someone for the year they were born, find out how old they are with a date object and a basic function, then it displays the age, and last part is with an if statement, if the persons age is over 40 it has to change the bgcolor to red. The thing is this template seems so far from what i need i cant figure out how to modify it or start from scratch...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> AGE CALCULATOR </TITLE>
<script>
var startTime = new Date();
var startInt = startTime.getTime();
var elapsedTime = new Date();
function getTime()
{
var output ="";
currentTime=new Date();
var currentInt = currentInt - startInt;
var elapsedInt = currentInt - startInt;
elapsedTime = new Date (elapsedInt);
output += elapsedTime.getMinutes()+":";
output += elapsedTime.getMilliseconds()+"\n";
document.myForm.txtOutput.value +=output;
}
</script>
</HEAD>
<BODY bgcolor=tan text=black>
<h1><center><b>Date Object</b></center>
<hr><hr>
</h1>
<center>
<form name="myForm">
<table border=4>
<tr>
<td><input type="button" value="Get Time"
onClick="getTime()">
</td>
<td><input type="text" name="textOutput">
</td>
</tr>
</HTML>
</table>
</form>
</body>
//main thing is i dont understand how the new Date getYear commands work,
i assume i prompt for year, get the current year and subtract difference, than a simple if statement for bgcolor, but i just cant apply it. Someone plzzz help!!!!!!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> AGE CALCULATOR </TITLE>
<script>
var startTime = new Date();
var startInt = startTime.getTime();
var elapsedTime = new Date();
function getTime()
{
var output ="";
currentTime=new Date();
var currentInt = currentInt - startInt;
var elapsedInt = currentInt - startInt;
elapsedTime = new Date (elapsedInt);
output += elapsedTime.getMinutes()+":";
output += elapsedTime.getMilliseconds()+"\n";
document.myForm.txtOutput.value +=output;
}
</script>
</HEAD>
<BODY bgcolor=tan text=black>
<h1><center><b>Date Object</b></center>
<hr><hr>
</h1>
<center>
<form name="myForm">
<table border=4>
<tr>
<td><input type="button" value="Get Time"
onClick="getTime()">
</td>
<td><input type="text" name="textOutput">
</td>
</tr>
</HTML>
</table>
</form>
</body>
//main thing is i dont understand how the new Date getYear commands work,
i assume i prompt for year, get the current year and subtract difference, than a simple if statement for bgcolor, but i just cant apply it. Someone plzzz help!!!!!!!