473,799 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calendar problem.

296 Contributor
Hello,

I have developed a calendar program in Javascript which opens a calendar as a popup window and when a user clicks on a date the date is copied into the parent windows textbox.

The code of the parent window is as follows -->

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <title>calendar</title>
  4. </head>
  5.  
  6. <body>
  7. <input type="text" name="parent"/>
  8. <a href="javascript:void(0);" onClick=window.open("cal_popup.html");>Click here to open the calendar window</a>
  9. </body>
  10.  
  11. </html>

The code of the popup window is like this -->

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <title>Calendar</title>
  5. <script language="javascript" type="text/javascript">
  6.  
  7. function post_value(mm,dt,yy){
  8. opener.document.parent.value = mm + "/" + dt + "/" + yy;
  9. self.close();
  10. }
  11.  
  12.  
  13. function gen_cal(prm,chm) {
  14.     myDate = new Date();
  15.  
  16.     var m,d,y;
  17.     if(prm){
  18.     m=prm+chm;
  19.     }
  20.     else{
  21.     m= myDate.getMonth();
  22.     }
  23.  
  24.     d= myDate.getDate(); // Finds today's date
  25.     y= myDate.getFullYear(); // Finds today's year
  26.  
  27.     var string = new Date(y,m,d);
  28.     var newstring = string.toString();
  29.     var string_array = newstring.split(" ");
  30.  
  31.  
  32. //    mn --> Month is calculated to display at the top of the calendar for eg: Jan
  33.     var mn = string_array[1];
  34.  
  35.     //yn--> Year is calculated to display at the top of the calendar for eg: 2007
  36.     var yn = string_array[5];
  37.  
  38.     //no_of_days -->This is to calculate number of days in a month
  39.     var no_of_days;
  40.     if(mn == "Jan" || mn == "Mar" || mn == "May" || mn == "Jul" || mn == "Aug" || mn == "Oct" || mn == "Dec")
  41.         no_of_days = 31;
  42.     if(mn == "Apr" || mn == "Jun" || mn == "Sep" || mn == "Nov")
  43.         no_of_days = 30;
  44.     if(mn == "Feb")
  45.         if(yn % 4 == 0)
  46.         no_of_days = 29;
  47.         else
  48.         no_of_days = 28;
  49.  
  50.     //j--> This will have the week day of the first day of the month
  51.     myArray = new Array("Sun", "Mon", "Tue", "Wed", "Thu","Fri", "Sat");
  52.     myDate1 = new Date(y,m,1);
  53.     var newdate1 = myDate1.toString();
  54.     var string_date = newdate1.split(" ");
  55.     var j = string_date[0];
  56.  
  57.     for(i=0;i<myArray.length;i++) {
  58.         if(myArray[i] == j)
  59.         j=i;
  60.     }
  61.  
  62.     var adj = "<td>&nbsp;</td>";
  63.     for(k=2; k<=j; k++){ // Adjustment of date starting
  64.         adj = adj + "<td>&nbsp;</td>";
  65.     }
  66.  
  67.     // Starting of top line showing name of the days of the week
  68.  
  69.     document.write(" <table border='1' bordercolor='#FFFF00' cellspacing='0' cellpadding='0' align=center><tr><td>");
  70.  
  71.     document.write("<table cellspacing='0' cellpadding='0' align=center width='100' border='1'><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='javascript:gen_cal("+m+",-1);'><</a> </td><td colspan=5 align=center bgcolor='#ffff00'><font size='3' face='Tahoma'>" + mn + yn + "</td><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='javascript:gen_cal("+m+",1);'>></a> </td></tr><tr>");
  72.  
  73.     document.write("<td><font size='3' face='Tahoma'><b>Sun</b></font></td><td><font size='3' face='Tahoma'><b>Mon</b></font></td><td><font size='3' face='Tahoma'><b>Tue</b></font></td><td><font size='3' face='Tahoma'><b>Wed</b></font></td><td><font size='3' face='Tahoma'><b>Thu</b></font></td><td><font size='3' face='Tahoma'><b>Fri</b></font></td><td><font size='3' face='Tahoma'><b>Sat</b></font></td></tr><tr>");
  74.  
  75.     ////// End of the top line showing name of the days of the week//////////
  76.  
  77.     //////// Starting of the days//////////
  78.     var pv;
  79.     for(i=1;i<=no_of_days;i++){
  80.         pv = m + "," + i + "," + yn;
  81.         document.write(adj + "<td valign=top><font size='2' face='Tahoma'><a href='#'onClick='post_value("+pv+");'>" + i + "</a><br>");
  82.         // This will display the date inside the calendar cell
  83.         document.write(" </font></td>");
  84.         adj='';
  85.         j++;
  86.         if(j==7){
  87.             document.write("</tr><tr>");
  88.             j=0;
  89.         }
  90.     }
  91.     document.write("</tr></table></td></tr></table>");
  92. }
  93.  
  94.  
  95. </script>
  96. </head>
  97.  
  98. <body onLoad="javascript:gen_cal();">
  99. </body>
  100. </html>
Please copy them in two files and run in IE .


There are 2 PROBLEMS -->
1.The month navigation is not working .
2. When we click on a date it should get copied inside a textbox which is not happening.

Please help me in solving this as its very urgent.
May 27 '07 #1
7 1729
pbmods
5,821 Recognized Expert Expert
Please copy them in two files and run in IE .
If you wanted us to do that, why didn't you just upload your two text files as attachments?
May 28 '07 #2
pankajit09
296 Contributor
If you wanted us to do that, why didn't you just upload your two text files as attachments?
How to upload files as attachment ?
May 28 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Put your text box inside form tags so you can reference it properly. Also, avoid using names like "parent". You could give it an id instead and use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(yourid).value=...
May 28 '07 #4
pankajit09
296 Contributor
I am facing problem in the below section. Its the NAVIGATION part -->


Expand|Select|Wrap|Line Numbers
  1.     document.write("<table cellspacing='0' cellpadding='0' align=center width='100' border='1'><td align=center bgcolor='#ffff00'><font size='3'> <a href='javascript:gen_cal("+m+",-1);'><</a> </td><td colspan=5 align=center bgcolor='#4444ff'><font size='3' color='white'><b>" + mn + yn + "</b></td><td align=center bgcolor='#ffff00'><font size='3'> <a href='javascript:gen_cal("+m+",1);'>></a> </td></tr><tr>");


Please help.
May 28 '07 #5
pankajit09
296 Contributor
ok I have uploaded the two files.


cal_popup.html
http://www.megaupload. com/?d=X4ROLHVI


calendar.html
http://www.megaupload. com/?d=P7OP46BY


Please run them in IE and solve the problem.

Only "Navigation " is the problem.
May 29 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
What error do you get? Is this problem only in IE or have you not tested on other browsers?
May 29 '07 #7
pankajit09
296 Contributor
What error do you get? Is this problem only in IE or have you not tested on other browsers?

First please run those files then you will come to know the problem.

Its just a syntax problem of document.write .
May 29 '07 #8

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

Similar topics

16
3063
by: DFS | last post by:
If you're listening, I want the middle of the calendar (showing 1 month) to open below the cursor position. It currently opens just to the right and below the cursor position. I hunted through the code, but can't determine what to alter. Very nice piece of work, by the way. Thanks
5
4600
by: Miguel Dias Moura | last post by:
Hello, i am trying to create a .css file with several styles and apply them to the calendar control so i can change the look of: 1. Text Type and Format (Bold, Underline, etc) 2. Background Color 3. Foreground Color 4. Border Tickness 5. Border Color
0
1747
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
2
3419
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many controls (i.e. roundedcorners component www.4guysfromrolla.com], buttons and panels) functions like a tab control. The buttons are programmatically designed to make the corresponding panel visible. Sample aspx.vb code:
3
2636
by: =?Utf-8?B?UGFycm90?= | last post by:
I applied the following Ajax code in my web page which has a calendar control to keep my page from completely reloading everytime something was changed. <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/> <atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional"> <ContentTemplate> After inserting this code, my calendar stopped working in that if I clicked on a date, nothing would...
24
9699
by: =?Utf-8?B?Tkg=?= | last post by:
I have a basic calendar and a SelectionChanged event (asp.net 2.0). How can I handle it when a user chooses the same date again, in this case the SelectionChanged event is not fired because, well, the date selected hasnt changed. Is there a calendar.clearSelection type method on the calendar I can use?
3
2743
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can assist with this. Thanks in advance. I have an access database that i have added a pop up calendar to, the Table information for the Date Reported field is Date/Time format short date, input mask is 00/00/0000.
0
3329
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
4
3369
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters the comments and clicks the save button then the date and the date will be stored in the mysql database. This is working fine. But my problem is when, after the user had made an entry the date in the calendar for which an entry has made should be...
0
9543
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
10257
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
10029
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...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6808
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
5467
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
4144
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
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.