SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: HTML problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTML problem

    Thanks for the time,
    I am in the process creating a calender for my website using HTML script. I would like to highlight the background for the date of the present day. In other words today is March 15. I would like March 15 to be highlighted on my calander. Tomorrow is March 16. Is there a way to move the highlighted background to March 16 automatically tomorrow without manually changing my calender script every remaining day of the year. I know you can acheive this with PHP, but I am not PHP literate yet. Here is an HTML example of a calender program. If it is possible to modify this program to highlight the date automatically without fiddling with the HTML file everyday for the rest of the year please let me know.

    <TABLE BORDER=3 CELLSPACING=3 CELLPADDING=3>
    <TR>
    <TD COLSPAN="7" ALIGN=center><B>December 2001</B></TD>
    </TR>

    <TR>
    <TD COLSPAN="7" ALIGN=center><I>Another year comes to an end</I></TD>
    </TR>

    <TR>
    <TD ALIGN=center>Sun</TD>
    <TD ALIGN=center>Mon</TD>
    <TD ALIGN=center>Tue</TD>
    <TD ALIGN=center>Wed</TD>
    <TD ALIGN=center>Thu</TD>
    <TD ALIGN=center>Fri</TD>
    <TD ALIGN=center>Sat</TD>
    </TR>

    <TR>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center>1</TD>
    </TR>

    <TR>
    <TD ALIGN=center>2</TD>
    <TD ALIGN=center>3</TD>
    <TD ALIGN=center>4</TD>
    <TD ALIGN=center>5</TD>
    <TD ALIGN=center>6</TD>
    <TD ALIGN=center>7</TD>
    <TD ALIGN=center>8</TD>
    </TR>

    <TR>
    <TD ALIGN=center>9</TD>
    <TD ALIGN=center>10</TD>
    <TD ALIGN=center>11</TD>
    <TD ALIGN=center>12</TD>
    <TD ALIGN=center>13</TD>
    <TD ALIGN=center>14</TD>
    <TD ALIGN=center>15</TD>
    </TR>

    <TR>
    <TD ALIGN=center>16</TD>
    <TD ALIGN=center>17</TD>
    <TD ALIGN=center>18</TD>
    <TD ALIGN=center>19</TD>
    <TD ALIGN=center>20</TD>
    <TD ALIGN=center>21</TD>
    <TD ALIGN=center>22</TD>
    </TR>

    <TR>
    <TD ALIGN=center>23</TD>
    <TD ALIGN=center>24</TD>
    <TD ALIGN=center>25</TD>
    <TD ALIGN=center>26</TD>
    <TD ALIGN=center>27</TD>
    <TD ALIGN=center>28</TD>
    <TD ALIGN=center>29</TD>
    </TR>

    <TR>
    <TD ALIGN=center>30</TD>
    <TD ALIGN=center>31</TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>
    <TD ALIGN=center></TD>

    </TR>

    </TABLE>






    Thanks,

    DAD

  2. #2
    Carpe Diem = Fish of the Day fisherboy's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically, no.

    You can use javascript to report todays date in text easily enough, eg Today is March 16, 2007.

    It may be feasible to set up something with javascript but I wouldn't know how, nor how big the js file would be.

    Doing it server side with PHP sounds more sensible.

    Good luck.
    fisherboy
    Web Site Design

  3. #3
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    I would recommend doing it in PHP (it'd be relatively simple), but if you'd like, there are different ways this can be done with Javascript. The easiest would probably be to assign each cell an ID (the date of each cell), and then replace the contents of that ID with an update version, i.e.
    HTML Code:
    <html>
     <head>
      <script type="text/javascript">
       function updateToday() {
        var now = new Date();
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var day = now.getDate();
        if(month < 10) {
         month = "0" + month;
        }
        if(day < 10) {
         day = "0" + day;
        }
        today = year + "-" + month + "-" + day;
        document.getElementById(today).innerHTML = "<strong>" + today + "</strong>";
       }
    
       window.onload = updateToday;
      </script>
     </head>
     <body>
      <table>
       <tr>
        <th>Monday</th>
        <th>Tuesday</th>
        <th>Wedensday</th>
        <th>Thursday</th>
        <th>Friday</th>
        <th>Saturday</th>
        <th>Sunday</th>
       </tr>
       <tr>
        <td><span class="date" id="2007-03-12">2007-03-12</span>
            <span class="contents"></span></td>
        <td><span id="2007-03-13">2007-03-13</span>
            <span class="contents"></td>
        <td><span id="2007-03-14">2007-03-14</span>
            <span class="contents"></td>
        <td><span id="2007-03-15">2007-03-15</span>
            <span class="contents"></td>
        <td><span id="2007-03-16">2007-03-16</span>
            <span class="contents"></td>
        <td><span id="2007-03-17">2007-03-17</span>
            <span class="contents"></td>
        <td><span id="2007-03-18">2007-03-18</span>
            <span class="contents"></td>
       </tr>
       <tr>
        <td><span id="2007-03-19">2007-03-19</span>
            <span class="contents"></td>
        <td><span id="2007-03-20">2007-03-20</span>
            <span class="contents"></td>
        <td><span id="2007-03-21">2007-03-21</span>
            <span class="contents"></td>
        <td><span id="2007-03-22">2007-03-22</span>
            <span class="contents"></td>
        <td><span id="2007-03-23">2007-03-23</span>
            <span class="contents"></td>
        <td><span id="2007-03-24">2007-03-24</span>
            <span class="contents"></td>
        <td><span id="2007-03-25">2007-03-25</span>
            <span class="contents"></td>
       </tr>
      </table>
     </body>
    </html>
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  4. #4
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do it with PHP. Have PHP fetch the current date and then have it output an ID attribute on the table cell. While I don't know how to do this per se (don't blame me, I just woke up - I don't code early in the morning for a reason) I do have a script lying around that does just that. Have the script fetch the current date, assign the TD with that date an ID, and then style it with CSS.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If you can find it.....

    When you get around to finding that script can you forward it? No hurry, I have a lot of issues (regarding programming of course). I have a 435pg PHP book to read. Just trying to get my ducks in a row. Also, if you have one, can you recommend a message board service?

  6. #6
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll forward it to you when I find it. As for message board services, do you mean a forum script? If so, there are two I recommend. One is free, the other is not. For the free script, go to www.simplemachines.org and download SMF. For the commercial script, go with vBulletin.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •