Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date will not display if a table. 1

Status
Not open for further replies.

vemate

Programmer
Aug 23, 2002
61
US
What is wrong with this javascript I want it to display the date in a nice box. But I get nothing to display.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Display Date</title>
</head>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Display Date</title>
</head>

<style type="text/css">
body {background-color: tan: ;}

table {background-color: peach;
border-style: outset;
border-color: green;}


td {font-family: Comic Sans MS;
font size: 16pt;
font-weight: bold;
color: brown;}
</style></head>
<script language="javascript" type="text/javascript">
Today = new Date ( );
document.write("Today's Date is: " + Today.getmonth() + "/" + Today.getdate() + "/" + Today.getyear());
</script>
</table>
</body>
</html>
 
You have extra tags in your code.

The 6th line is a duplicate <html> tag and then on the 8th line starts a second <head> with a second <title>

and then on down a bit you have a 3rd </head> when you only ever opened 2 heads....

Is this some kind of April Fools joke?
 
sorry, it should have said:

The 6th line is a duplicate <head> tag ....


But still, it seems like a joke!
 
What is wrong? Numerous things.

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Display Date</title>

<style type="text/css">
    body {background-color: tan: ;}

table {background-color: peach;
    border-style: outset;
    border-color: green;}


td {font-family: Comic Sans MS;
    font-size: 16pt;
    font-weight: bold;
    color: brown;}
</style>
</head>

<body>
<table>
  <tr>
    <td>
<script language="javascript" type="text/javascript">
Today = new Date ( );
document.write("Today's Date is: " + Today.getMonth() + "/" + Today.getDate() + "/" + Today.getFullYear());
</script>
    </td>
  </tr>
</table>

</body>
</html>

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
to elaborate:

. getMonth(), getDate() and getYear() are case-sensitive
. use getFullYear() instead
. font-size needs a hyphen
. you have numerous <head> and <body> tags
. you need opening <tr> and <td> tags
. style definitions should be between the <head></head> tags

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Oh, except the .getMonth returns a 0 to 11 so you need to add 1.

I think the point of all this is to get us to debug something horrible and then show that it is April 1st!
 
Thanks for the help. I was so upset because I could not get this to work I forgot about it being Case-Sensitive. The duplications were there because I copied it and did not notice I copied it twice.

It is working now.

Thanks very much for your help.
 
Well now I feel like a real @$$ after what I said and it turned out to be a real problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top