JavaScript Calendar Assignment

Discussion in 'OT Technology' started by doggfather, Oct 15, 2005.

  1. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    The assignment is to make a calendar that works for every month

    could someone help me? This is what I have so far:

    <html>
    <head>
    <title>Calendar</title>
    </head>
    <body>
    <script type="text/javascript">
    var currentTime = new Date();
    var month = currentTime.getMonth();
    var day = currentTime.getDay();
    var d01 =
    if (month = 0) {daysinMonth=31};
    if (month = 1) {daysinMonth=28};
    if (month = 2) {daysinMonth=31};
    if (month = 3) {daysinMonth=30};
    if (month = 4) {daysinMonth=31};
    if (month = 5) {daysinMonth=30};
    if (month = 6) {daysinMonth=31};
    if (month = 7) {daysinMonth=31};
    if (month = 8) {daysinMonth=30};
    if (month = 9) {daysinMonth=31};
    if (month = 10) {daysinMonth=30};
    if (month = 11) {daysinMonth=31};
    //for (i=0; i<=daysinMonth; i++) {

    document.write("<table border=1 cellpadding=1 cellspacing=1>")
    document.write("<th>Sunday</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> ")
    document.write("<tr>"+d01+"</tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ")
    document.write("<tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ")
    document.write("<tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ")
    document.write("<tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ")
    document.write("<tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> ")
    //document.write(i+"<br />");
    document.write("</table>")

    //}
    </script>
    </body>
    </html>
     
  2. samm

    samm Next in Line

    Joined:
    Dec 22, 2000
    Messages:
    2,630
    Likes Received:
    0
    Location:
    San Jose, CA
    what are you having trouble with?
     
  3. doggfather

    doggfather New Member

    Joined:
    Aug 6, 2005
    Messages:
    224
    Likes Received:
    0
    I need to get it so inside the <tr></tr> there will print numbers for dates

    but the dates have to be like universal, the script has to print it so it prints the calendar of each month
     
  4. krondo

    krondo New Member

    Joined:
    Oct 5, 2005
    Messages:
    153
    Likes Received:
    0
    Location:
    Manhizzle KS
    uh...maybe you should do a loop to get it to print each day inside the <th></th> tags, because what you got there is just pringting 1 day correct? and i'm pretty sure you're not showing what month it is either so you can't really check....but most likely a loop man.
     

Share This Page