This is a discussion on "Urgent help in Javascript calendar display" within the JavaScript Forum section. This forum, and the thread "Urgent help in Javascript calendar display are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Urgent help in Javascript calendar display
|
||
| Notices |
![]() |
|
|
LinkBack (1) | Thread Tools |
|
|||
|
Urgent help in Javascript calendar display
hi,
I need a urgent help..as i am stuck in this calendar javascript code. The below code generate a 12 months calendar. I know how to reduce the number of months etc but want to have a next and previous button which will display the next month. I am not able to put a next and prev month. I need to display only one month and then next or prev month is displayed by clicking on the buttons. Please help me. Thanks in advance PS. code is attached <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <b> Current availability calendar: <script language=JavaScript1.2 type=text/javascript> <!-- var apartmentin="mosman"; //--> </script> <table dir=ltr cellspacing=1 cellpadding=1 width="100%" border=0> <tbody> <tr> <td valign=top><!--availCal_start--> <script language=JavaScript1.2 type=text/javascript> var apartment = apartmentin; //Specify bgcolor of calendar var bg="#F0EEEF" //Specify font size var fs=1 // table height var tbh = 0 // 200 // table width var tbw = 0 // 150 // cell width var wd=10 // 22 // cell height var ht=10 // 22 // border var bd = 0 // 1 // available cell background acbg = " bgcolor=#C37C50 " // unavailable cell background ucbg = " bgcolor=#F6A472 " var flg = 0; //var fs = 1; M = new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December"); D = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); function setAvailability() { pdy = new Date(); // today pmo = pdy.getMonth(); // present month pyr = pdy.getFullYear(); // present year var j = 0; for (var i=0; i < 12; i++) { if (j == 0) document.write('<TABLE BORDER=1><TR><TD VALIGN=TOP>'); document.write(''); yr = (pmo==12?pyr+1 mo = (pmo==12?0 bgn = new Date(M[mo]+" 1,"+yr); // assign to date Calendar(); // Send month to screen if (j == 3) { document.write('</TD></TR></TABLE>'); j = 0; } else { document.write('</TD><TD VALIGN=TOP>'); j++; } pmo++; if (pmo == 12) { pmo= 0; pyr++; } } document.write('</TD></TR></TABLE>'); // Finish up } function Calendar() { var rows = 0; calendar = 1; dy = bgn.getDay(); yr = eval(yr); d = "312831303130313130313031"; if (yr / 4 == Math.floor(yr / 4)) { d = d.substring(0, 2) + "29" + d.substring(4, d.length); } pos = (mo * 2); ld = eval(d.substring(pos, pos + 2)); document.write("<TABLE BORDER=" + bd + " cellspacing=0" + " style=border-collapse: collapse" + " HEIGHT=" + tbh + " WIDTH=" + tbw + " BGCOLOR='" + bg + "'><TR><TD ALIGN=CENTER COLSPAN=7>" + "<FONT SIZE=" + fs + ">" + M[mo] + " " + yr + "</FONT></TD></TR><TR><TR>"); rows++; for (var i = 0;i < 7;i ++) { document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + ">" +"<FONT SIZE="+fs+">" + D[i] + "</FONT></TD>"); } document.write("</TR><TR>"); rows++ ctr = 0; for (var i = 0;i < 7; i++) { if (i < dy) { document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + ">" +"<FONT SIZE=" + fs + "> </FONT>" +" </TD>"); } else { ctr++; if (available() == 1) { cbg = acbg; } else { cbg = ucbg; } document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + cbg + ">" + "<FONT SIZE=" + fs + ">" + ctr + "</FONT>" + "</TD>"); } } document.write("</TR><TR>"); rows++; while (ctr < ld) { for (var i = 0;i < 7; i++) { ctr++; if (ctr > ld) { document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + ">" + " </TD>"); } else { if (available() == 1) { cbg = acbg; } else { cbg = ucbg; } document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + cbg + ">" + "<FONT SIZE=" + fs + ">" + ctr + "</FONT>" + "</TD>"); } } document.write("</TR><TR>"); rows++; } if (rows <= 7) { for (var i = 0;i < 7; i++) { document.write("<TD ALIGN=CENTER WIDTH=" + wd + " HEIGHT=" + ht + ">" + " </TD>"); } } document.write("</TR></TABLE>"); } apartmentArray = new Array("h001","o002","h005","s010","s012","m004","r 007","r004","r008","s011","m001","o004","o001","h0 03","s004","m011","m005","m007","e003","w002","w00 1","r002","r003","Lady112","v001","Rocklands41","s 116","m008","Keats610","Queenvic14","Alison212","a 002","c005","b003","Greatwest38","j001","Carillon3 06","Wellington52","b004"); function available() { cd = bgn; cd.setDate(ctr); if (apartment == "mosman") return(available_mosman()); if (apartment == "o002") return(available_o002()); return(0); } function available_mosman() { sd = new Date(2006,0,00); ed = new Date(2006,3,31); if (cd >= sd & cd < ed) return(1); if (cd >= sd & cd <= ed & calendar == 0) return(1); sd = new Date(2006,5,21); ed = new Date(2006,6,06); if (cd >= sd & cd < ed) return(1); if (cd >= sd & cd <= ed & calendar == 0) return(1); sd = new Date(2006,6,07); ed = new Date(2006,6,10); if (cd >= sd & cd < ed) return(1); if (cd >= sd & cd <= ed & calendar == 0) return(1); return(0); } </script> <!--availCal_end--> <script language=JavaScript1.2 type=text/javascript> setAvailability(); document.write("<table><tr><td " + acbg + ">         &nb sp  </td><td> - available </td></tr></table>"); document.write("<table><tr><td " + ucbg + ">         &nb sp  </td><td> - not available</td></tr></table>"); </script> </td> </tr> </tbody> </table> </b> </body> </html> |
|
|
|
|||
|
You're code doesn't work becuase there are some smilies in it...
Last edited by AnneJan; Jan 8th, 2006 at 14:34. |
|
|||
|
And here's another calendar (scroll months, you can change the colours):
|
![]() |
| Tags |
| urgent, help, javascript, calendar, display |
| Thread Tools | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.webforumz.com/javascript-forum/4737-urgent-help-in-javascript-calendar-display.htm
|
||||
| Posted By | For | Type | Date | |
| Javascript setMonth Function | This thread | Refback | Feb 21st, 2007 00:51 | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Image display help.. [URGENT :( ] | jahphill | Web Page Design | 6 | Jun 6th, 2008 02:37 |
| Calendar Display | jakesterguy | JavaScript Forum | 1 | Aug 20th, 2007 22:24 |
| Clean Calendar ( Javascript / CSS / DHTML ) | iMarc | JavaScript Forum | 10 | Mar 3rd, 2007 15:02 |
| JavaScript Menu - HELP Plz , URGENT | prismmb | JavaScript Forum | 1 | Oct 13th, 2006 17:49 |
| Urgent Javascript Help | gambit79 | JavaScript Forum | 21 | Sep 26th, 2006 09:40 |