472,373 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

Help with calender

Hi all,

In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the date from calender
Expand|Select|Wrap|Line Numbers
  1. and clicks search button it will fetch data from database. But what I need is as soon the user clicks the date, it should fetch data for that date from database. How to do it. Here is the code I am using
  2.  
  3.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • <html>
  • <script type="text/javascript">
  • function Show(){     
  •  
  •  
  •     var date_id = document.getElementById("date_id").value;
  •  
  •     
  •  
  •  
  •  
  • CreateRequest();
  •  
  • var URL='display.php';
  •  
  • request.open("POST",URL,true);
  •  
  • request.onreadystatechange=handleHttpResponse;
  •  
  • request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  •  
  • request.send("id="+escape(date_id));
  • }
  • </script>
  •  
  • <body>
  • <script type="text/javascript" src="date-picker.js"></script>
  • <form name="Calender1">
  • <a STYLE="text-decoration: none" onmouseover="window.status='Date Picker';return true;" onmouseout="window.status='';return true;" href="javascript:show_calendar('Calender1.date_id')" >
  • <IMG height=21 src="calendar.gif" width=30 border=0></a>
  • <input type="textbox" class="textBox" type="text" name="date_id" id="date_id" size="10">
  • <input type="submit" value="Search" onclick="Show()">
  • </form>
  • </body>
  • </html>

  • And this the date-picker.js code


    Expand|Select|Wrap|Line Numbers
    1. var weekend = [0,6];
    2.  
    3. var weekendColor = "#e0e0e0";
    4.  
    5. var fontface = "Verdana";
    6.  
    7. var fontsize = 2;
    8.  
    9.  
    10.  
    11. var gNow = new Date();
    12.  
    13. var ggWinCal;
    14.  
    15. isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
    16.  
    17. isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
    18.  
    19.  
    20.  
    21. Calendar.Months = ["January", "February", "March", "April", "May", "June",
    22.  
    23. "July", "August", "September", "October", "November", "December"];
    24.  
    25.  
    26.  
    27. // Non-Leap year Month days..
    28.  
    29. Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    30.  
    31. // Leap year Month days..
    32.  
    33. Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    34.  
    35.  
    36.  
    37. function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {
    38.  
    39.     if ((p_month == null) && (p_year == null))    return;
    40.  
    41.  
    42.  
    43.     if (p_WinCal == null)
    44.  
    45.         this.gWinCal = ggWinCal;
    46.  
    47.     else
    48.  
    49.         this.gWinCal = p_WinCal;
    50.  
    51.  
    52.  
    53.     if (p_month == null) {
    54.  
    55.         this.gMonthName = null;
    56.  
    57.         this.gMonth = null;
    58.  
    59.         this.gYearly = true;
    60.  
    61.     } else {
    62.  
    63.         this.gMonthName = Calendar.get_month(p_month);
    64.  
    65.         this.gMonth = new Number(p_month);
    66.  
    67.         this.gYearly = false;
    68.  
    69.     }
    70.  
    71.  
    72.  
    73.     this.gYear = p_year;
    74.  
    75.     this.gFormat = p_format;
    76.  
    77.     this.gBGColor = "white";
    78.  
    79.     this.gFGColor = "black";
    80.  
    81.     this.gTextColor = "black";
    82.  
    83.     this.gHeaderColor = "black";
    84.  
    85.     this.gReturnItem = p_item;
    86.  
    87. }
    88.  
    89.  
    90.  
    91. Calendar.get_month = Calendar_get_month;
    92.  
    93. Calendar.get_daysofmonth = Calendar_get_daysofmonth;
    94.  
    95. Calendar.calc_month_year = Calendar_calc_month_year;
    96.  
    97. Calendar.print = Calendar_print;
    98.  
    99.  
    100.  
    101. function Calendar_get_month(monthNo) {
    102.  
    103.     return Calendar.Months[monthNo];
    104.  
    105. }
    106.  
    107.  
    108.  
    109. function Calendar_get_daysofmonth(monthNo, p_year) {
    110.  
    111.     /* 
    112.  
    113.     Check for leap year ..
    114.  
    115.     1.Years evenly divisible by four are normally leap years, except for... 
    116.  
    117.     2.Years also evenly divisible by 100 are not leap years, except for... 
    118.  
    119.     3.Years also evenly divisible by 400 are leap years. 
    120.  
    121.     */
    122.  
    123.     if ((p_year % 4) == 0) {
    124.  
    125.         if ((p_year % 100) == 0 && (p_year % 400) != 0)
    126.  
    127.             return Calendar.DOMonth[monthNo];
    128.  
    129.  
    130.  
    131.         return Calendar.lDOMonth[monthNo];
    132.  
    133.     } else
    134.  
    135.         return Calendar.DOMonth[monthNo];
    136.  
    137. }
    138.  
    139.  
    140.  
    141. function Calendar_calc_month_year(p_Month, p_Year, incr) {
    142.  
    143.     /* 
    144.  
    145.     Will return an 1-D array with 1st element being the calculated month 
    146.  
    147.     and second being the calculated year 
    148.  
    149.     after applying the month increment/decrement as specified by 'incr' parameter.
    150.  
    151.     'incr' will normally have 1/-1 to navigate thru the months.
    152.  
    153.     */
    154.  
    155.     var ret_arr = new Array();
    156.  
    157.  
    158.  
    159.     if (incr == -1) {
    160.  
    161.         // B A C K W A R D
    162.  
    163.         if (p_Month == 0) {
    164.  
    165.             ret_arr[0] = 11;
    166.  
    167.             ret_arr[1] = parseInt(p_Year) - 1;
    168.  
    169.         }
    170.  
    171.         else {
    172.  
    173.             ret_arr[0] = parseInt(p_Month) - 1;
    174.  
    175.             ret_arr[1] = parseInt(p_Year);
    176.  
    177.         }
    178.  
    179.     } else if (incr == 1) {
    180.  
    181.         // F O R W A R D
    182.  
    183.         if (p_Month == 11) {
    184.  
    185.             ret_arr[0] = 0;
    186.  
    187.             ret_arr[1] = parseInt(p_Year) + 1;
    188.  
    189.         }
    190.  
    191.         else {
    192.  
    193.             ret_arr[0] = parseInt(p_Month) + 1;
    194.  
    195.             ret_arr[1] = parseInt(p_Year);
    196.  
    197.         }
    198.  
    199.     }
    200.  
    201.  
    202.  
    203.     return ret_arr;
    204.  
    205. }
    206.  
    207.  
    208.  
    209. function Calendar_print() {
    210.  
    211.     ggWinCal.print();
    212.  
    213. }
    214.  
    215.  
    216.  
    217. function Calendar_calc_month_year(p_Month, p_Year, incr) {
    218.  
    219.     /* 
    220.  
    221.     Will return an 1-D array with 1st element being the calculated month 
    222.  
    223.     and second being the calculated year 
    224.  
    225.     after applying the month increment/decrement as specified by 'incr' parameter.
    226.  
    227.     'incr' will normally have 1/-1 to navigate thru the months.
    228.  
    229.     */
    230.  
    231.     var ret_arr = new Array();
    232.  
    233.  
    234.  
    235.     if (incr == -1) {
    236.  
    237.         // B A C K W A R D
    238.  
    239.         if (p_Month == 0) {
    240.  
    241.             ret_arr[0] = 11;
    242.  
    243.             ret_arr[1] = parseInt(p_Year) - 1;
    244.  
    245.         }
    246.  
    247.         else {
    248.  
    249.             ret_arr[0] = parseInt(p_Month) - 1;
    250.  
    251.             ret_arr[1] = parseInt(p_Year);
    252.  
    253.         }
    254.  
    255.     } else if (incr == 1) {
    256.  
    257.         // F O R W A R D
    258.  
    259.         if (p_Month == 11) {
    260.  
    261.             ret_arr[0] = 0;
    262.  
    263.             ret_arr[1] = parseInt(p_Year) + 1;
    264.  
    265.         }
    266.  
    267.         else {
    268.  
    269.             ret_arr[0] = parseInt(p_Month) + 1;
    270.  
    271.             ret_arr[1] = parseInt(p_Year);
    272.  
    273.         }
    274.  
    275.     }
    276.  
    277.  
    278.  
    279.     return ret_arr;
    280.  
    281. }
    282.  
    283.  
    284.  
    285. // This is for compatibility with Navigator 3, we have to create and discard one object before the prototype object exists.
    286.  
    287. new Calendar();
    288.  
    289.  
    290.  
    291. Calendar.prototype.getMonthlyCalendarCode = function() {
    292.  
    293.     var vCode = "";
    294.  
    295.     var vHeader_Code = "";
    296.  
    297.     var vData_Code = "";
    298.  
    299.  
    300.  
    301.     // Begin Table Drawing code here..
    302.  
    303.     vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";
    304.  
    305.  
    306.  
    307.     vHeader_Code = this.cal_header();
    308.  
    309.     vData_Code = this.cal_data();
    310.  
    311.     vCode = vCode + vHeader_Code + vData_Code;
    312.  
    313.  
    314.  
    315.     vCode = vCode + "</TABLE>";
    316.  
    317.  
    318.  
    319.     return vCode;
    320.  
    321. }
    322.  
    323.  
    324.  
    325. Calendar.prototype.show = function() {
    326.  
    327.     var vCode = "";
    328.  
    329.  
    330.  
    331.     this.gWinCal.document.open();
    332.  
    333.  
    334.  
    335.     // Setup the page...
    336.  
    337.     this.wwrite("<html>");
    338.  
    339.     this.wwrite("<head><title>Calendar</title>");
    340.  
    341.     this.wwrite("</head>");
    342.  
    343.  
    344.  
    345.     this.wwrite("<body " + 
    346.  
    347.         "link=\"" + this.gLinkColor + "\" " + 
    348.  
    349.         "vlink=\"" + this.gLinkColor + "\" " +
    350.  
    351.         "alink=\"" + this.gLinkColor + "\" " +
    352.  
    353.         "text=\"" + this.gTextColor + "\">");
    354.  
    355.     this.wwriteA("<FONT COLOR='RED' FACE='" + fontface + "' SIZE=2><B>");
    356.  
    357.     this.wwriteA(this.gMonthName + " " + this.gYear);
    358.  
    359.     this.wwriteA("</B><BR>");
    360.  
    361.  
    362.  
    363.     // Show navigation buttons
    364.  
    365.     var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
    366.  
    367.     var prevMM = prevMMYYYY[0];
    368.  
    369.     var prevYYYY = prevMMYYYY[1];
    370.  
    371.  
    372.  
    373.     var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
    374.  
    375.     var nextMM = nextMMYYYY[0];
    376.  
    377.     var nextYYYY = nextMMYYYY[1];
    378.  
    379.  
    380.  
    381.     this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR bgcolor=e0e0e0><TD ALIGN=center>");
    382.  
    383.     this.wwrite("<A HREF=\"" +
    384.  
    385.         "javascript:window.opener.Build(" + 
    386.  
    387.         "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
    388.  
    389.         ");" +
    390.  
    391.         "\"><<<\/A>           </TD><TD ALIGN=center>");
    392.  
    393.     this.wwrite("<A HREF=\"" +
    394.  
    395.         "javascript:window.opener.Build(" + 
    396.  
    397.         "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
    398.  
    399.         ");" +
    400.  
    401.         "\"><<\/A></TD><TD ALIGN=center>");
    402.  
    403.     this.wwrite("  <A HREF=\"javascript:none();\"></A>             </TD><TD ALIGN=center>");
    404.  
    405.     this.wwrite("  <A HREF=\"" +
    406.  
    407.         "javascript:window.opener.Build(" + 
    408.  
    409.         "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
    410.  
    411.         ");" +
    412.  
    413.         "\">><\/A>            </TD><TD ALIGN=center>");
    414.  
    415.     this.wwrite("  <A HREF=\"" +
    416.  
    417.         "javascript:window.opener.Build(" + 
    418.  
    419.         "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
    420.  
    421.         ");" +
    422.  
    423.         "\">>><\/A>           </TD></TR></TABLE><BR>");
    424.  
    425.  
    426.  
    427.     // Get the complete calendar code for the month..
    428.  
    429.     vCode = this.getMonthlyCalendarCode();
    430.  
    431.     this.wwrite(vCode);
    432.  
    433.  
    434.  
    435.     this.wwrite("</font></body></html>");
    436.  
    437.     this.gWinCal.document.close();
    438.  
    439. }
    440.  
    441.  
    442.  
    443. Calendar.prototype.showY = function() {
    444.  
    445.     var vCode = "";
    446.  
    447.     var i;
    448.  
    449.     var vr, vc, vx, vy;        // Row, Column, X-coord, Y-coord
    450.  
    451.     var vxf = 285;            // X-Factor
    452.  
    453.     var vyf = 200;            // Y-Factor
    454.  
    455.     var vxm = 10;            // X-margin
    456.  
    457.     var vym;                // Y-margin
    458.  
    459.     if (isIE)    vym = 75;
    460.  
    461.     else if (isNav)    vym = 25;
    462.  
    463.  
    464.  
    465.     this.gWinCal.document.open();
    466.  
    467.  
    468.  
    469.     this.wwrite("<html>");
    470.  
    471.     this.wwrite("<head><title>Calendar</title>");
    472.  
    473.     this.wwrite("<style type='text/css'>\n<!--");
    474.  
    475.     for (i=0; i<12; i++) {
    476.  
    477.         vc = i % 3;
    478.  
    479.         if (i>=0 && i<= 2)    vr = 0;
    480.  
    481.         if (i>=3 && i<= 5)    vr = 1;
    482.  
    483.         if (i>=6 && i<= 8)    vr = 2;
    484.  
    485.         if (i>=9 && i<= 11)    vr = 3;
    486.  
    487.  
    488.  
    489.         vx = parseInt(vxf * vc) + vxm;
    490.  
    491.         vy = parseInt(vyf * vr) + vym;
    492.  
    493.  
    494.  
    495.         this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
    496.  
    497.     }
    498.  
    499.     this.wwrite("-->\n</style>");
    500.  
    501.     this.wwrite("</head>");
    502.  
    503.  
    504.  
    505.     this.wwrite("<body " + 
    506.  
    507.         "link=\"" + this.gLinkColor + "\" " + 
    508.  
    509.         "vlink=\"" + this.gLinkColor + "\" " +
    510.  
    511.         "alink=\"" + this.gLinkColor + "\" " +
    512.  
    513.         "text=\"" + this.gTextColor + "\">");
    514.  
    515.     this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
    516.  
    517.     this.wwrite("Year : " + this.gYear);
    518.  
    519.     this.wwrite("</B><BR>");
    520.  
    521.  
    522.  
    523.     // Show navigation buttons
    524.  
    525.     var prevYYYY = parseInt(this.gYear) - 1;
    526.  
    527.     var nextYYYY = parseInt(this.gYear) + 1;
    528.  
    529.  
    530.  
    531.     this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");
    532.  
    533.     this.wwrite("[<A HREF=\"" +
    534.  
    535.         "javascript:window.opener.Build(" + 
    536.  
    537.         "'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'" +
    538.  
    539.         ");" +
    540.  
    541.         "\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
    542.  
    543.     this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
    544.  
    545.     this.wwrite("[<A HREF=\"" +
    546.  
    547.         "javascript:window.opener.Build(" + 
    548.  
    549.         "'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
    550.  
    551.         ");" +
    552.  
    553.         "\">>><\/A>]</TD></TR></TABLE><BR>");
    554.  
    555.  
    556.  
    557.     // Get the complete calendar code for each month..
    558.  
    559.     var j;
    560.  
    561.     for (i=11; i>=0; i--) {
    562.  
    563.         if (isIE)
    564.  
    565.             this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
    566.  
    567.         else if (isNav)
    568.  
    569.             this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
    570.  
    571.  
    572.  
    573.         this.gMonth = i;
    574.  
    575.         this.gMonthName = Calendar.get_month(this.gMonth);
    576.  
    577.         vCode = this.getMonthlyCalendarCode();
    578.  
    579.         this.wwrite(this.gMonthName + "-" + this.gYear + "<BR>");
    580.  
    581.         this.wwrite(vCode);
    582.  
    583.  
    584.  
    585.         if (isIE)
    586.  
    587.             this.wwrite("</DIV>");
    588.  
    589.         else if (isNav)
    590.  
    591.             this.wwrite("</LAYER>");
    592.  
    593.     }
    594.  
    595.  
    596.  
    597.     this.wwrite("</font><BR></body></html>");
    598.  
    599.     this.gWinCal.document.close();
    600.  
    601. }
    602.  
    603.  
    604.  
    605. Calendar.prototype.wwrite = function(wtext) {
    606.  
    607.     this.gWinCal.document.writeln(wtext);
    608.  
    609. }
    610.  
    611.  
    612.  
    613. Calendar.prototype.wwriteA = function(wtext) {
    614.  
    615.     this.gWinCal.document.write(wtext);
    616.  
    617. }
    618.  
    619.  
    620.  
    621. Calendar.prototype.cal_header = function() {
    622.  
    623.     var vCode = "";
    624.  
    625.  
    626.  
    627.     vCode = vCode + "<TR>";
    628.  
    629.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
    630.  
    631.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
    632.  
    633.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
    634.  
    635.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
    636.  
    637.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
    638.  
    639.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='14%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
    640.  
    641.     vCode = vCode + "<TD BGCOLOR='96aac8' WIDTH='16%'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
    642.  
    643.     vCode = vCode + "</TR>";
    644.  
    645.  
    646.  
    647.     return vCode;
    648.  
    649. }
    650.  
    651.  
    652.  
    653. Calendar.prototype.cal_data = function() {
    654.  
    655.     var vDate = new Date();
    656.  
    657.     vDate.setDate(1);
    658.  
    659.     vDate.setMonth(this.gMonth);
    660.  
    661.     vDate.setFullYear(this.gYear);
    662.  
    663.  
    664.  
    665.     var vFirstDay=vDate.getDay();
    666.  
    667.     var vDay=1;
    668.  
    669.     var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
    670.  
    671.     var vOnLastDay=0;
    672.  
    673.     var vCode = "";
    674.  
    675.  
    676.  
    677.     /*
    678.  
    679.     Get day for the 1st of the requested month/year..
    680.  
    681.     Place as many blank cells before the 1st day of the month as necessary. 
    682.  
    683.     */
    684.  
    685.  
    686.  
    687.     vCode = vCode + "<TR>";
    688.  
    689.     for (i=0; i<vFirstDay; i++) {
    690.  
    691.         vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
    692.  
    693.     }
    694.  
    695.  
    696.  
    697.     // Write rest of the 1st week
    698.  
    699.     for (j=vFirstDay; j<7; j++) {
    700.  
    701.         vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
    702.  
    703.             "<A HREF='#' " + 
    704.  
    705.                 "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
    706.  
    707.                 this.format_data(vDay) + 
    708.  
    709.                 "';window.close();\">" + 
    710.  
    711.                 this.format_day(vDay) + 
    712.  
    713.             "</A>" + 
    714.  
    715.             "</FONT></TD>";
    716.  
    717.         vDay=vDay + 1;
    718.  
    719.     }
    720.  
    721.     vCode = vCode + "</TR>";
    722.  
    723.  
    724.  
    725.     // Write the rest of the weeks
    726.  
    727.     for (k=2; k<7; k++) {
    728.  
    729.         vCode = vCode + "<TR>";
    730.  
    731.  
    732.  
    733.         for (j=0; j<7; j++) {
    734.  
    735.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" + 
    736.  
    737.                 "<A HREF='#' " + 
    738.  
    739.                     "onClick=\"self.opener.document." + this.gReturnItem + ".value='" + 
    740.  
    741.                     this.format_data(vDay) + 
    742.  
    743.                     "';window.close();\">" + 
    744.  
    745.                 this.format_day(vDay) + 
    746.  
    747.                 "</A>" + 
    748.  
    749.                 "</FONT></TD>";
    750.  
    751.             vDay=vDay + 1;
    752.  
    753.  
    754.  
    755.             if (vDay > vLastDay) {
    756.  
    757.                 vOnLastDay = 1;
    758.  
    759.                 break;
    760.  
    761.             }
    762.  
    763.         }
    764.  
    765.  
    766.  
    767.         if (j == 6)
    768.  
    769.             vCode = vCode + "</TR>";
    770.  
    771.         if (vOnLastDay == 1)
    772.  
    773.             break;
    774.  
    775.     }
    776.  
    777.  
    778.  
    779.     // Fill up the rest of last week with proper blanks, so that we get proper square blocks
    780.  
    781.     for (m=1; m<(7-j); m++) {
    782.  
    783.         if (this.gYearly)
    784.  
    785.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
    786.  
    787.             "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
    788.  
    789.         else
    790.  
    791.             vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) + 
    792.  
    793.             "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
    794.  
    795.     }
    796.  
    797.  
    798.  
    799.     return vCode;
    800.  
    801. }
    802.  
    803.  
    804.  
    805. Calendar.prototype.format_day = function(vday) {
    806.  
    807.     var vNowDay = gNow.getDate();
    808.  
    809.     var vNowMonth = gNow.getMonth();
    810.  
    811.     var vNowYear = gNow.getFullYear();
    812.  
    813.  
    814.  
    815.     if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
    816.  
    817.         return ("<FONT COLOR=\"RED\"><B>" + vday + "</B></FONT>");
    818.  
    819.     else
    820.  
    821.         return (vday);
    822.  
    823. }
    824.  
    825.  
    826.  
    827. Calendar.prototype.write_weekend_string = function(vday) {
    828.  
    829.     var i;
    830.  
    831.  
    832.  
    833.     // Return special formatting for the weekend day.
    834.  
    835.     for (i=0; i<weekend.length; i++) {
    836.  
    837.         if (vday == weekend[i])
    838.  
    839.             return (" BGCOLOR=\"" + weekendColor + "\"");
    840.  
    841.     }
    842.  
    843.  
    844.  
    845.     return "";
    846.  
    847. }
    848.  
    849.  
    850.  
    851. Calendar.prototype.format_data = function(p_day) {
    852.  
    853.     var vData;
    854.  
    855.     var vMonth = 1 + this.gMonth;
    856.  
    857.     vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
    858.  
    859.     var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
    860.  
    861.     var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
    862.  
    863.     var vY4 = new String(this.gYear);
    864.  
    865.     var vY2 = new String(this.gYear.substr(2,2));
    866.  
    867.     var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;
    868.  
    869.  
    870.  
    871.     switch (this.gFormat) {
    872.  
    873.         case "MM\/DD\/YYYY" :
    874.  
    875.             vData = vMonth + "\/" + vDD + "\/" + vY4;
    876.  
    877.             break;
    878.  
    879.         case "MM\/DD\/YY" :
    880.  
    881.             vData = vMonth + "\/" + vDD + "\/" + vY2;
    882.  
    883.             break;
    884.  
    885.         case "MM-DD-YYYY" :
    886.  
    887.             vData = vMonth + "-" + vDD + "-" + vY4;
    888.  
    889.             break;
    890.  
    891.         case "MM-DD-YY" :
    892.  
    893.             vData = vMonth + "-" + vDD + "-" + vY2;
    894.  
    895.             break;
    896.  
    897.  
    898.  
    899.         case "DD\/MON\/YYYY" :
    900.  
    901.             vData = vDD + "\/" + vMon + "\/" + vY4;
    902.  
    903.             break;
    904.  
    905.         case "DD\/MON\/YY" :
    906.  
    907.             vData = vDD + "\/" + vMon + "\/" + vY2;
    908.  
    909.             break;
    910.  
    911.         case "DD-MON-YYYY" :
    912.  
    913.             vData = vDD + "-" + vMon + "-" + vY4;
    914.  
    915.             break;
    916.  
    917.         case "DD-MON-YY" :
    918.  
    919.             vData = vDD + "-" + vMon + "-" + vY2;
    920.  
    921.             break;
    922.  
    923.  
    924.  
    925.         case "DD\/MONTH\/YYYY" :
    926.  
    927.             vData = vDD + "\/" + vFMon + "\/" + vY4;
    928.  
    929.             break;
    930.  
    931.         case "DD\/MONTH\/YY" :
    932.  
    933.             vData = vDD + "\/" + vFMon + "\/" + vY2;
    934.  
    935.             break;
    936.  
    937.         case "DD-MONTH-YYYY" :
    938.  
    939.             vData = vDD + "-" + vFMon + "-" + vY4;
    940.  
    941.             break;
    942.  
    943.         case "DD-MONTH-YY" :
    944.  
    945.             vData = vDD + "-" + vFMon + "-" + vY2;
    946.  
    947.             break;
    948.  
    949.  
    950.  
    951.         case "DD\/MM\/YYYY" :
    952.  
    953.             vData = vDD + "\/" + vMonth + "\/" + vY4;
    954.  
    955.             break;
    956.  
    957.         case "DD\/MM\/YY" :
    958.  
    959.             vData = vDD + "\/" + vMonth + "\/" + vY2;
    960.  
    961.             break;
    962.  
    963.         case "DD-MM-YYYY" :
    964.  
    965.             vData = vDD + "-" + vMonth + "-" + vY4;
    966.  
    967.             break;
    968.  
    969.         case "DD-MM-YY" :
    970.  
    971.             vData = vDD + "-" + vMonth + "-" + vY2;
    972.  
    973.             break;
    974.  
    975.         case "YYYY-MM-DD" :
    976.  
    977.             vData = vY4 + "-" + vMonth + "-" + vDD;
    978.  
    979.             break;
    980.  
    981.  
    982.  
    983.         default :
    984.  
    985.         //    vData = vMonth + "\/" + vDD + "\/" + vY4;
    986.  
    987.             vData = vY4 +"-"+vMonth + "-" + vDD ;
    988.  
    989.     }
    990.  
    991.  
    992.  
    993.     return vData;
    994.  
    995. }
    996.  
    997.  
    998.  
    999. function Build(p_item, p_month, p_year, p_format) {
    1000.  
    1001.     var p_WinCal = ggWinCal;
    1002.  
    1003.     gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);
    1004.  
    1005.  
    1006.  
    1007.     // Customize your Calendar here..
    1008.  
    1009.     gCal.gBGColor="white";
    1010.  
    1011.     gCal.gLinkColor="black";
    1012.  
    1013.     gCal.gTextColor="black";
    1014.  
    1015.     gCal.gHeaderColor="darkgreen";
    1016.  
    1017.  
    1018.  
    1019.     // Choose appropriate show function
    1020.  
    1021.     if (gCal.gYearly)    gCal.showY();
    1022.  
    1023.     else    gCal.show();
    1024.  
    1025. }
    1026.  
    1027.  
    1028.  
    1029. function show_calendar() {
    1030.  
    1031.     /* 
    1032.  
    1033.         p_month : 0-11 for Jan-Dec; 12 for All Months.
    1034.  
    1035.         p_year    : 4-digit year
    1036.  
    1037.         p_format: Date format (mm/dd/yyyy, dd/mm/yy, ...)
    1038.  
    1039.         p_item    : Return Item.
    1040.  
    1041.     */
    1042.  
    1043.  
    1044.  
    1045.     p_item = arguments[0];
    1046.  
    1047.     if (arguments[1] == null)
    1048.  
    1049.         p_month = new String(gNow.getMonth());
    1050.  
    1051.     else
    1052.  
    1053.         p_month = arguments[1];
    1054.  
    1055.     if (arguments[2] == "" || arguments[2] == null)
    1056.  
    1057.         p_year = new String(gNow.getFullYear().toString());
    1058.  
    1059.     else
    1060.  
    1061.         p_year = arguments[2];
    1062.  
    1063.     if (arguments[3] == null)
    1064.  
    1065.         p_format = "YYYY-MM-DD";
    1066.  
    1067.     else
    1068.  
    1069.         p_format = arguments[3];
    1070.  
    1071.  
    1072.  
    1073.     vWinCal = window.open("", "Calendar", 
    1074.  
    1075.         "width=250,height=250,status=no,resizable=no,top=200,left=200");
    1076.  
    1077.     vWinCal.opener = self;
    1078.  
    1079.     ggWinCal = vWinCal;
    1080.  
    1081.  
    1082.  
    1083.     Build(p_item, p_month, p_year, p_format);
    1084.  
    1085. }
    1086.  
    1087. /*
    1088.  
    1089. Yearly Calendar Code Starts here
    1090.  
    1091. */
    1092.  
    1093. function show_yearly_calendar(p_item, p_year, p_format) {
    1094.  
    1095.     // Load the defaults..
    1096.  
    1097.     if (p_year == null || p_year == "")
    1098.  
    1099.         p_year = new String(gNow.getFullYear().toString());
    1100.  
    1101.     if (p_format == null || p_format == "")
    1102.  
    1103.         p_format = "YYYY-MM-DD";
    1104.  
    1105.  
    1106.  
    1107.     var vWinCal = window.open("", "Calendar", "scrollbars=yes");
    1108.  
    1109.     vWinCal.opener = self;
    1110.  
    1111.     ggWinCal = vWinCal;
    1112.  
    1113.  
    1114.  
    1115.     Build(p_item, null, p_year, p_format);
    1116.  
    1117. }


    Can anyone please help me. I am stuck up at this point. Please give me some idea. Or is there any other alternative to achieve this functionality apart from using this javascript calender. If anybody of you have done similar type of appllcation with any other php calender code, please please help me

    With regards
    Feb 25 '08 #1
    7 2241
    harshmaul
    490 Expert 256MB
    Did you still have the "problem with the calender"?
    Feb 25 '08 #2
    Yes, could you please help me
    Feb 25 '08 #3
    harshmaul
    490 Expert 256MB
    I would love to. Whats the problem
    Feb 25 '08 #4
    ronverdonk
    4,258 Expert 4TB
    This is an interesting discussion. But I think I miss something or I don't see it. Could we all share the problem?

    Ronald
    Feb 25 '08 #5
    Markus
    6,050 Expert 4TB
    I think there is a problem with the length of his question.
    If you use the reply to his OP you can see the large amount of code he submitted.
    Feb 25 '08 #6
    harshmaul
    490 Expert 256MB
    I think there is a problem with the length of his question.
    If you use the reply to his OP you can see the large amount of code he submitted.
    Thanks for spotting that.

    All you need to do is wire up the submit button to some PHP code.

    and in the page that button submits too read it in like this...

    Expand|Select|Wrap|Line Numbers
    1. $date = $_GET['date_id'];
    Feb 25 '08 #7
    Thanks for spotting that.

    All you need to do is wire up the submit button to some PHP code.

    and in the page that button submits too read it in like this...

    Expand|Select|Wrap|Line Numbers
    1. $date = $_GET['date_id'];

    Thanks for your reply. But my problem is I don't need submit button, when the user selects the date from the calendar I just need that date into the php variable so that I can write a mysql query with date variable.

    With regards
    Feb 26 '08 #8

    Sign in to post your reply or Sign up for a free account.

    Similar topics

    1
    by: dcinfinite | last post by:
    hi.. i have a few other questions 2 ask..i used the "calender" function to insert Date of Birth for my "add customer form" is that advisible?coz i feel it'll be easy for customers to just click...
    1
    by: progII | last post by:
    Hello, i am struggling the whole night cos of my c++ homework. deadline is very soon. (april 4th) i have to implement a calender. i store every calender entry in a list. a calender entry is...
    4
    by: Chris | last post by:
    Hi, I am trying to create a popup calender so a user can click on a button on the main form, a calender will then popup, the user will select a date and then click ok on the popup. The date will...
    5
    by: Chris | last post by:
    Hi, I have been trying for days, yes days, to use the calender from the asp.net timetracker starter kit. I am now frustrated. I finally get the popup calender to popup but when I click ok to...
    0
    by: kalichakradhar | last post by:
    hi all, hi, I am developing a application which would open the shared calender of outlook and read the meeting notices and also modifies the meeting notice from Vb.I am successful in opening the...
    2
    by: iniyan | last post by:
    guys i'm new for asp.i alredy had a calender script and i had atched it at <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <script type="text/javascript"...
    1
    by: ajos | last post by:
    hi friends, Im developing a web based project in struts framework, i have certain forms in them, which contain date field among others. For this purpose i got a calender pop-up from here tigra ....
    4
    Vkas
    by: Vkas | last post by:
    HELLO!!!!!!!!!!!!! me using ASP.net 2.0, language VB.net! working tool Visula studio.Net 2005 I HAVE CREATED A simple WEB User control (calender.ascx) having a text box , a button, and...
    21
    Vkas
    by: Vkas | last post by:
    i had created my own web calender control!!!! it consist 1} text box (it display's the selected date) 2} button (it hide and show the calender control) 3} calender control (use for the selection...
    2
    by: Kemmylinns12 | last post by:
    Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
    1
    by: Matthew3360 | last post by:
    Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
    0
    Oralloy
    by: Oralloy | last post by:
    Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
    0
    BLUEPANDA
    by: BLUEPANDA | last post by:
    At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
    0
    by: Rahul1995seven | last post by:
    Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
    1
    by: Johno34 | last post by:
    I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
    1
    by: ezappsrUS | last post by:
    Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
    0
    by: jack2019x | last post by:
    hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
    0
    DizelArs
    by: DizelArs | last post by:
    Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.