
Originally Posted by
rowf33
<h4>Days Calculator for the Date:
<script type="text/javascript">//![CDATA[
var dateselect = new Date()
document.write(year+ "/"+ month +"/" + day)
// ]]></script>
</h4>
<table id="datetable" border="1">
<tbody>
<tr>
<td id="headerrow" style="text-align: center;">3 day</td>
<td id="headerrow" style="text-align: center;">7 day</td>
<td id="headerrow" style="text-align: center;">30 day</td>
<td id="headerrow" style="text-align: center;">90 day</td>
</tr>
<tr>
<td>
<script type="text/javascript">// <![CDATA[
document.write(dateselect+3);
// ]]></script>
</td>
<td>
<script type="text/javascript">// <![CDATA[
document.write(dateselect+7);
// ]]></script>
</td>
<td>
<script type="text/javascript">// <![CDATA[
document.write(dateselect+30);
// ]]></script>
</td>
1) Either don't do this with JavaScript or do the whole thing with JavaScript. Vast numbers of users don't use JavaScript and they'll be thinking that you're an idiot when they see the headings but not the dates.
2) The CDATA designations only go with XHTML but you should never use document.write with XHTML.
3) You should not be using TABLES for layout.
PHP Code:
<?php
define ('DATE_FORMAT', 'Y-m-d');
foreach (array (3, 7, 30, 90) as $days) echo "<div>$days days: ", date (DATE_FORMAT, strtotime ("+ $days days")), "</div>\n";
?>
Bookmarks