Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

Creating a Calendar

I need to make a calendar which is to be used in an ASP page.
I wat to know if :
1) I can use a Java Applet which displays the calendar alongwith my ASP page and if yes how do I pass information between the two??
2) If I want to create the calendar as a separate ASP page...can anyone get me the logic.

1 Solution

       to create a calender for asp. the best way is to use javascript and dhtml. you can use java applet also but why do make page heavy by creating heavy java applets.

logic is as follows

- find the current year : year
- find the current month : month
- create the function to get the total no of days in the current month:daysInMonth()
- create a function getMonthByName() which wil return month name for month number.
- create a function dateClicked that will handle date clicked event
 - create function nextMonth() and prevMonth() which will set the current month.
- after getting all this data you are ready to draw calender.
- set ID of the body as doc
- web calender is nothing but its a normal html table

start creating table as following


var firstDate = new Date(year, month - 1,1);
var firstDay = firstDate.getDay();
var bStart = false;

var row = 6;
var col = 7;
var HTML = "";
///////////// Calender Heading
HTML += "<table border='0' style='border-collapse: collapse; border:1 solid #a9a9a9; ' bordercolor='#111111' width='150' height='125' bgcolor='white'>"

HTML += "<tr >"
HTML += "<td id='ArrowLeft' align=center height=10 style='border-bottom:1 solid #a9a9a9; background:#c0c0c0' width='17'><font face='Marlett' size='3'><a  href='#' onclick='prevMonth();return false' class='Arrow' onmouseMove='status=\"Previous Month\"'>3</a></font></td>"

HTML += "<td colspan=5 align=center height=10 style='border-bottom:1 solid #a9a9a9; background:#c0c0c0'>" + getMonthByName() + "</td>"

HTML += "<td align=center height=10 style='border-bottom:1 solid #a9a9a9; background:#c0c0c0' width='22'><font face='Marlett' size='3'><a href='#' class='Arrow' onclick='nextMonth();return false' onmouseMove='status=\"Next Month\"' >4</a></font></td>"

HTML += "</tr>"

    ////////////// Days Notations
    HTML += "<tr> "
    HTML += "<td width='17' height='10' bgcolor='#FFFFFF' class='daynotation'>S</td>"
    HTML += "<td width='17' height='10' bgcolor='#FFFFFF' class='daynotation'>M</td>"

    HTML += "<td width='16' height='10' bgcolor='#FFFFFF' class='daynotation'>T</td>"
    HTML += "<td width='16' height='10' bgcolor='#FFFFFF' class='daynotation'>W</td>"

    HTML += "<td width='16' height='10' bgcolor='#FFFFFF' class='daynotation'>T</td>"
    HTML += "<td width='16' height='10' bgcolor='#FFFFFF' class='daynotation'>F</td>"

    HTML += "<td width='22' height='10' bgcolor='#FFFFFF' class='daynotation'>S</td>"
     HTML += "</tr>"
     //////////////////// Calendar Calcuation Start ////////////////

     var counter = 0;
     for (row=0; row<6; row++)
          HTML += "<tr>"
          for(col=0; col<7; col++)
               if (firstDay == col && bStart == false)
                    bStart = true;

               if (bStart == false)
                    HTML += "<td>&nbsp;</td>";
                    HTML += "<td ><a class='date' href='#' onmousemove='status=\"" + getMonthByName(month) + " " + counter + ", " + year + "\"' onclick='dateClicked(counter); return false;' id='id" + counter + "'>" + counter + "</a></td>";
               if (counter >= daysInMonth())
          HTML += "</tr>"
          if (counter >= daysInMonth())
     HTML += "</table>";
     doc.innerHTML = HTML;



m aamir maniar

This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now