473,841 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with calender

59 New Member
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 2378
    harshmaul
    490 Recognized Expert Contributor
    Did you still have the "problem with the calender"?
    Feb 25 '08 #2
    gubbachchi
    59 New Member
    Yes, could you please help me
    Feb 25 '08 #3
    harshmaul
    490 Recognized Expert Contributor
    I would love to. Whats the problem
    Feb 25 '08 #4
    ronverdonk
    4,258 Recognized Expert Specialist
    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 Recognized Expert Expert
    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 Recognized Expert Contributor
    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
    gubbachchi
    59 New Member
    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
    1129
    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 on the date and month in the calender for thier DOB..but is this method appropriate since the Calender defalut displays the year starting from 2005? besides that, i'm using "regular expression validator" to validate the "email" field. the...
    1
    1523
    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 a struct with entry, date, time, type. the problem is: if i use the change-function to add a (optional) time to an
    4
    2685
    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 then be passed back to the main form and populate a textbox. I tried two options. None worked. First. I used the popup calender form the time tracker starter kit. On my page I have an image buton. In the click event I have the foll code
    5
    2045
    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 insert the date to the calling page I get the error "A runtime error has occured Line 14
    0
    1414
    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 shared calender but now how can i read/write the contents of the shared calender. please provide me the syntax of functions that can acheive the purpose in VB. I have one more problem when i execute the code.. it gives a popup window saying that...
    2
    1406
    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" src="calenderDateInput.js"> </script> </HEAD> nw i'm not sure hw 2 call this script so i can view the calender when online.i located the imej beside the year text box.where this calender had to call the year text box.hope u guys can help me.i'm blur whre to...
    1
    2022
    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 . The calender works perfectly fine for plain old jsp files but when i tried it for my jsp page with struts tags its not working...why is this behaviour shown with struts tags? ive had many a trouble with the struts tags earlier. how can i make it work...
    4
    3122
    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 a calender control
    21
    18624
    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 of the date) How it works!!!! user clicks on the button calender control becomes visible user selects a date from calender control
    0
    9864
    marktang
    by: marktang | last post by:
    ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
    0
    9703
    by: Hystou | last post by:
    Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
    0
    10926
    Oralloy
    by: Oralloy | last post by:
    Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
    0
    10609
    jinu1996
    by: jinu1996 | last post by:
    In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
    0
    10302
    tracyyun
    by: tracyyun | last post by:
    Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
    0
    9445
    agi2029
    by: agi2029 | last post by:
    Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
    0
    7024
    by: conductexam | last post by:
    I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
    0
    5691
    by: TSSRALBI | last post by:
    Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
    1
    4498
    by: 6302768590 | last post by:
    Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

    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.