Ad:
 
Similar Threads
Jul 26th, 2010
0

JavaScript Calendar (and possibly some php) - Update calendar depending on month

Expand Post »
Hi All.
Now I am really stuck here.

I am trying to develop a calendar which hilights the days date (which I have done) but now I am on to the really tricky bit (for me). I need the calendar to change each month and because the different months have different days of the week for a day in that month and also don't have the same number of days I had to come to all of you because I don't know where to start. I have the code here if it helps and any help would be very much appreciated.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div class="cmonth">
  2. <div class="ctrl">
  3. <table cellspacing="0" cellpadding="0">
  4. <tr>
  5. <td align="left" style="width: 15px;">
  6. <a class="calendar_prev" href="#">&laquo;</a>
  7. </td>
  8. <td align="center">
  9. <span><strong><?php echo date('F Y'); ?></strong></span>
  10. </td>
  11. <td align="right" style="width: 15px;">
  12. <a class="calendar_next" href="#">&raquo;</a>
  13. </td>
  14. </tr>
  15. </table>
  16. </div>
  17. </div>
  18. <div class="cont">
  19. <ul class="chead">
  20. <li>
  21. <span>Sun</span>
  22. </li>
  23. <li>
  24. <span>Mon</span>
  25. </li>
  26. <li>
  27. <span>Tue</span>
  28. </li>
  29. <li>
  30. <span>Wed</span>
  31. </li>
  32. <li>
  33. <span>Thu</span>
  34. </li>
  35. <li>
  36. <span>Fri</span>
  37. </li>
  38. <li>
  39. <span>Sat</span>
  40. </li>
  41. </ul>
  42. <ul id='theDates' class="cdays">
  43. <li>
  44. <a href="">1</a>
  45. </li>
  46. <li>
  47. <a href="">2</a>
  48. </li>
  49. <li>
  50. <a href="">3</a>
  51. </li>
  52. <li>
  53. <a href="">4</a>
  54. </li>
  55. <li>
  56. <a href="#">5</a>
  57. </li>
  58. <li>
  59. <a href="#">6</a>
  60. </li>
  61. <li>
  62. <a href="#">7</a>
  63. </li>
  64. <li>
  65. <a href="#">8</a>
  66. </li>
  67. <li>
  68. <a href="#">9</a>
  69. </li>
  70. <li>
  71. <a href="#">10</a>
  72. </li>
  73. <li>
  74. <a href="#">11</a>
  75. </li>
  76. <li>
  77. <a href="#">12</a>
  78. </li>
  79. <li>
  80. <a href="#">13</a>
  81. </li>
  82. <li>
  83. <a href="#">14</a>
  84. </li>
  85. <li>
  86. <a href="#">15</a>
  87. </li>
  88. <li>
  89. <a href="#">16</a>
  90. </li>
  91. <li>
  92. <a href="#">17</a>
  93. </li>
  94. <li>
  95. <a href="#">18</a>
  96. </li>
  97. <li>
  98. <a href="#">19</a>
  99. </li>
  100. <li>
  101. <a href="#">20</a>
  102. </li>
  103. <li>
  104. <a href="#">21</a>
  105. </li>
  106. <li>
  107. <a href="#">22</a>
  108. </li>
  109. <li>
  110. <a href="#">23</a>
  111. </li>
  112. <li>
  113. <a href="#">24</a>
  114. </li>
  115. <li>
  116. <a href="#">25</a>
  117. </li>
  118. <li>
  119. <a href="#">26</a>
  120. </li>
  121. <li>
  122. <a href="#">27</a>
  123. </li>
  124. <li>
  125. <a href="#">28</a>
  126. </li>
  127. <li>
  128. <a href="#">29</a>
  129. </li>
  130. <li>
  131. <a href="#">30</a>
  132. </li>
  133. <li>
  134. <a href="#">31</a>
  135. </li>
  136. </ul>
  137. </div>
  138. <script>
  139. now = new Date().getDate()
  140. var cAs = document.getElementById('theDates').getElementsByTagName('a')
  141. for (var j=cAs.length,i=0;i<j;i++){if (cAs[i].firstChild.data==now) {cAs[i].style.backgroundColor='blue';break} }
  142. </script>

Thank you in advance.
Cameron
Reputation Points: 10
Solved Threads: 0
Light Poster
doctorphp is offline Offline
28 posts
since Apr 2010
Jul 26th, 2010
0

Re: JavaScript Calendar (and possibly some php) - Update calendar depending on month

Quote ...
don't know where to start.
Read about the methods of the Date() object http://www.w3schools.com/jsref/jsref_obj_date.asp
fxm
Reputation Points: 39
Solved Threads: 73
Posting Pro
fxm is offline Offline
590 posts
since Apr 2010
Jul 26th, 2010
0

Re: JavaScript Calendar (and possibly some php) - Update calendar depending on month

Click to Expand / Collapse  Quote originally posted by fxm ...
Read about the methods of the Date() object http://www.w3schools.com/jsref/jsref_obj_date.asp
The link is broken.
Reputation Points: 10
Solved Threads: 0
Light Poster
doctorphp is offline Offline
28 posts
since Apr 2010
Jul 26th, 2010
0

Re: JavaScript Calendar (and possibly some php) - Update calendar depending on month

Quote ...
The link is broken.
The link was good when I posted it, and it is good now.

Even if it were broken, surely the obvious search for 'javascript date object' would find something useful.
fxm
Reputation Points: 39
Solved Threads: 73
Posting Pro
fxm is offline Offline
590 posts
since Apr 2010
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: iFrame dynamic resize not working correctly
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: JQuery Tabs and Ajax reload





About Us | Contact Us | Advertise | Acceptable Use Policy
Build Custom RSS Feed


Follow us on Twitter


© 2010 DaniWeb® LLC