hdub
11-27-2007, 10:40 PM
I was assigned a pretty simple javascript problem for an intro to csc class...and it just refuses to work! I've checked it in firebug, and there are NO errors...but when I click submit the from simply resets and fails to execute. Please, please help me.
<html>
<head>
<script language=Javascript>
function display()
{
var today = new Date();
var hours = today.getHours();
var helloMessage ="";
var name = "";
name = document.myform.name.value;
var cMonth = today.getMonth();
var day = today.getDate();
var year = today.getFullYear();
if (hours <12)
helloMessage = "Good Morning";
else if (hours >5)
helloMessage="Good Afternoon";
else if (hours <5)
helloMessage= "Good Evening";
var biM ="";
biM= document.input.myform.bmonth.value;
biM= parseInt(x);
var bY="";
bY= document.input.myform.biyear.value;
bY= parseInt(l);
l=cMonth-biM;
x= year-bY;
if (month < biM);
else l=12-(cMonth-biM);
document.write("<body>");
document.write( "It is " + month + "/" + day + "/" + year)
document.write("<br> <br>");
document.write(helloMessage + "+name+");
document.write( "You will be" +x+ "years in" +l+ "months");
document.write ("</body>");
document.write ("</html>");
document.close();
}
</script>
</head>
<body>
<form name="myform">
Name:
<input type="text" name="name" value="">
<br>
<br>
Birth Month (1-12):
<input type="text" name="bmonth" size="2" value="">
<br>
<br>
Birth Date (1-31):
<input type="text" name="bdate" size="2" value="">
<br>
<br>
Birth Year (19XX)
<input type="text" name="biyear" size="5" value="">
<br><br>
<input type="Submit" onclick ="display()" value="Submit">
</form>
</body>
</html>
thank you
<html>
<head>
<script language=Javascript>
function display()
{
var today = new Date();
var hours = today.getHours();
var helloMessage ="";
var name = "";
name = document.myform.name.value;
var cMonth = today.getMonth();
var day = today.getDate();
var year = today.getFullYear();
if (hours <12)
helloMessage = "Good Morning";
else if (hours >5)
helloMessage="Good Afternoon";
else if (hours <5)
helloMessage= "Good Evening";
var biM ="";
biM= document.input.myform.bmonth.value;
biM= parseInt(x);
var bY="";
bY= document.input.myform.biyear.value;
bY= parseInt(l);
l=cMonth-biM;
x= year-bY;
if (month < biM);
else l=12-(cMonth-biM);
document.write("<body>");
document.write( "It is " + month + "/" + day + "/" + year)
document.write("<br> <br>");
document.write(helloMessage + "+name+");
document.write( "You will be" +x+ "years in" +l+ "months");
document.write ("</body>");
document.write ("</html>");
document.close();
}
</script>
</head>
<body>
<form name="myform">
Name:
<input type="text" name="name" value="">
<br>
<br>
Birth Month (1-12):
<input type="text" name="bmonth" size="2" value="">
<br>
<br>
Birth Date (1-31):
<input type="text" name="bdate" size="2" value="">
<br>
<br>
Birth Year (19XX)
<input type="text" name="biyear" size="5" value="">
<br><br>
<input type="Submit" onclick ="display()" value="Submit">
</form>
</body>
</html>
thank you