|
Comments and Discussions
|
 |
 |
When I launch the demo page in I.E. 8, it works fine, but FireFox 4 give a message "There is a problem sending the command to the program."
You know what ol' Jack Burton says at a time like this...
|
|
|
|
 |
Hi DimondWolfe,
This script is rather old and I haven't revisited in a while, so I guess it probably has a few kinks to work out in newer browsers . I wrote an updated version for jQuery[^] - just confirmed that it also works in FF4. Hope that helps!
|
|
|
|
 |
Excellent! That is exactly what I'm looking for!
You know what ol' Jack Burton says at a time like this...
|
|
|
|
 |
Hello can anyone tell me please?
Depends of minDate how to rendar maxDate of cal2?
Means we are rendering two calendar..NOW IF user clicks on first that should be minDate of cal2 and also maxDate should be within range of 7.
Any answer will appreciate..
Help plz.
|
|
|
|
 |
Dear Karl Sir
No one has replied to my questions even you. So i was waiting. But now i solved it.
If need please let me know..!!
Thanks for the code
|
|
|
|
 |
First off, I'd like to say great work, you've saved me much time! I've gotten most of my mods to work (including having the events show up in a predefined div, rather than as an alert), but was wondering what JS code I would need to alter to have only the calendar appear? I'd like to have it without the input fields, and simply have the "next month" and "previous month" buttons. Is this possible?
|
|
|
|
 |
Hi, and thanks for your comment
The calendar is set to require at least one fallback input field. To get rid of the input fields, set the "fallback" property to 0 (It's called fallback_single in the script) and create a hidden field to pass to it. I'm afraid you'll still have to have that field in there, even if you're not actually doing anything with it.
<input type="hidden" id="tester" />
...
<script type="text/javascript">
cal1 = new Calendar ("cal1", "tester", new Date());
renderCalendar (cal1);
</script>
hth
|
|
|
|
 |
Thanks Karl, it should be fine with just the one input field, so I'll go with that. Again, great work!
|
|
|
|
 |
Thank u very much buddy for this amazing piece of work.It saved a lot of my time.
I've one question here....which date format shall I use to input the MinDate and MaxDate
values. My Idea is to restrict the user to select dates within this range only.
Or is there any way to do it?
|
|
|
|
 |
Hi, thanks for your message. Both minDate and maxDate take javascript Date objects, so you can just create a Date any way you like and pop it in there; the script will take care of the rest.
Example:
cal.maxDate = new Date();
hth
|
|
|
|
 |
First, I want to thank you for the code... It really help me...
Can we change the way to change the month ?? I want to use "Previous month" and "Next month" button instead of "typing" the date... If we can do that, how to make the existing text box and drop down list to be hidden ?? I tried some methods I know but it just make the calendar gone.
When people click on other date, the today's date no longer selected. How can we make today's date still selected ??
One more thing, how can I make Saturday NOT a holiday ??
Regards,
Ditya
modified on Tuesday, November 25, 2008 11:36 AM
|
|
|
|
 |
Hi Ditya... sorry for the delay in replying, somehow I missed the notification email.
For your questions:
- To make Saturdays count as a regular day, locate the following code in the script:
if ((currentDate.getUTCDay() == 0) || (currentDate.getUTCDay() == 6))
0 is Sunday, and 6 is Saturday - remove the condition for Saturdays to make Saturdays count as regular days.
- To avoid changing the date on click, remove the calls to selectDate in RenderDayEnabled and RenderDayEvent.
- Not sure what you mean about changing the way to change the month. You can set cal.scrollable = true to get the next and previous buttons. The calendar depends on the text boxes and drop downs, so you can't actually remove them; however I guess you could apply a display:none css class to them.
HTH
|
|
|
|
 |
Can anyone show/tell me how to go about doing the following to the calendar object so that when a certain day is clicked, it goes to a certain dynamic website.
User clicks a day, then a text file of data comes up corresponding to the day of the month they click on.
So far I know how to add the dates to the calendar object and make them appear blue with an underline, with this code:
cal1.eventDates = new Array(
new Array(curr_year + "/" + curr_month + "/" + curr_day, 1)
, new Array(curr_year + "/" + curr_month1 + "/" + curr_day1, 2)
Problem is that I need to make a loop so that 28 days back from the current date are underlined. I am having a lot of problems with that, I am not sure how to add a new sub array to an already exisiting Array. I was thinking of it in terms of putting the above code into one variable and putting the one variable like this:
cal1.eventDates = new Array(Back28Days); where Back28Days = new Array(Date, Counter), new Array(Date +1, Counter +1)); etc...
I think I got the event figured out to where if they click the day, it will open up a new windows with the data, I have a little work to do on the syntax of the window.open method, but I am also trying to display a dynamic webpage, here is an example:
http://......./ReportsFiles/Rep_(unique plant name)_1_(DayofMonth).txt
If there are any suggestiosn or help on any of this, mostly the first part, it would be much appreciated, thanks!
|
|
|
|
 |
Good evening Justin,
To make a day send the user to a page on click, modify the following function in the sample code:
<script type="text/javascript">
cal2 = new Calendar ("cal2", "tester2", new Date());
cal2.eventDates = new Array(
new Array("2005/2/10", 1)
, new Array("2005/2/12", 2)
, new Array("2005/2/14", 3)
);
myTextFiles = new Array();
myTextFiles['2005/2/10'] = "myfirstfile.txt";
myTextFiles['2005/2/12'] = "mysecondfile.txt";
myTextFiles['2005/2/14'] = "mythirdfile.txt";
cal2.scrolling = false;
cal2.selectEvent = function(eventId) { window.location = myTextFiles[eventId]; };
renderCalendar (cal2);
</script>
Re. Loops: I'm not sure why you would want to loop the way you described. The javascript would end up very large. You'd probably solve it more easily using some server side technology. Drop me a message if you have any questions
|
|
|
|
 |
Hello again,
Thanks for all your help, I understand the first part, I believe I was on the same track but using window.open instead, the way you suggested is definatley easier.
As for the loop I basically need it like the below code so that I have 28 new array objects inside the initial array. I, however, would not like to have 28 lines and so fourth to do this, instead I would rather have a loop that would increase the date and corresponding id number like I have below.
cal2.eventDates = new Array( new Array("2005/2/10", 1)
, new Array("2005/2/12", 2)
, new Array("2005/2/14", 3)
, new Array("2005/2/10", 4)
, new Array("2005/2/12", 5)
, new Array("2005/2/14", 6)
, new Array("2005/2/10", 7)
, new Array("2005/2/12", 8)
, new Array("2005/2/14", 9)
);
So I was thinking to make a variable TestDate = Test Date + new Array(Year, Month, Day, count), so that every time the loop went through it would add another new Array(Year, Month, Day, count), . So when I do the above code in my new setup I would have the following to include all of the subarrays:
cal2.eventDates = new Array(TestDate); This Test Date var would be equal to new Array(Date, Count) + new Array(Date, Count) etc...
But so far only the first "new Array(Date, Count)" works, and the rest do not. But your saying that it would be easier to use a JSP page or soemthing like that? I am not exactly sure how to interact JavaScript with that, any suggestions? Again thanks for all your help!!!
Justin
|
|
|
|
 |
Re: JSP - don't worry about that, I think I misunderstood what you wanted to do; a server side page would probably be overkill for the situation.
Try the following:
put this script block in the head for your page:
<script type="text/javascript" src="Calendar.js"></script>
<script type="text/javascript">
var uniquePlantName = "MYUNIQUEPLANTNAME";
var myTextFiles = new Array();
function SetupEvents(calendar, date, index)
{
var myDate = new Date(date);
for (var i = 0; i < 28; i++)
{
dateString = myDate.getFullYear() + "/" + (myDate.getMonth() +1) + "/" + myDate.getDate();
calendar.eventDates[calendar.eventDates.length] = new Array(dateString, index +i);
myTextFiles[dateString] = "http://whatever/ReportsFiles/Rep_" + uniquePlantName + "_1_(" + myDate.getDate() + ").txt";
myDate.setDate(myDate.getDate() -1);
}
}
</script>
Then put the following in the body:
<script type="text/javascript">
cal2 = new Calendar ("cal2", "tester2", new Date());
SetupEvents(cal2, "2008/10/29", 1);
cal2.scrolling = false;
cal2.selectEvent = function(eventId) { window.location = myTextFiles[eventId]; };
renderCalendar (cal2);
</script>
Both replace some html you should already have in your page.
As you can see in the SetupEvents function, all we have to do is use a for loop that will generate both the events and the links.
About the links: you might have a problem if your data spans more than one month, as the link only takes days into account. You might want to include the month (and year, if you need it) too.
HTH
|
|
|
|
 |
Thanks for all your help, I really appreciate it, the calendar works pretty much like I want it to, the only little thing I want to add to it is when the user clicks on a day that is underlined in the calendar (day with data), a new window appears with the data in it, but if the user goes back to the calendar page they cannot click on the same day they just clicked on without clicking off the day first, is there any easy way I can make it so that the user could click on the same day 1000 times. When the user goes back to the page they were on, the day is boldfaced, which is fine, but the user should be able to click on the day again and it bring up a file (if they accidendtally closed out of the data page).
For example the calendar object I am using has 28 days underlined in blue, in the calendar, to make an illlusion that a hyperlink is there. and there are 28 text files, 1 behind each day in an array like you showed me in a previous post. So if the user clicks a certain day that event ID will be the index of the array that holds the text files and it will open up that text file corresponding to the event ID that was clicked. If the user clicks today's date a text file will come up, showing the data the user needs, but if the user closes out of that window or tabs over to the calendar window and tries to click on the same day again, the link will not be there anymore. How can I get it so they could basically click all day on the same day and it would keep opening a file everytime they click.
Justin
|
|
|
|
 |
Try the following:
You can use the window.open(url, name) function (instead of setting window.location) in the event handler, to pop a window at the location of your file. If you specify the name of the window, the browser will use the same window if you click twice; if the window is not available, it will open a new one. The text file will still get reloaded, but at least, you won't get a few thousand windows running around.
To make the current date clickable, replace the lines in calendar.js containing
RenderDayEnabled (calendar, currentDate, calendar.todayDayStyle);
with
style = calendar.calendar.todayDayStyle
for (j=0; j < calendar.eventDates.length; j++)
{
if (calendar.eventDates[j][0] == currentDateString)
{
style = calendar.eventDayStyle;
RenderDayEvent (calendar, currentDate, style, calendar.eventDates[j][0]);
}
}
if (style == calendar.todayDayStyle)
{
RenderDayEnabled (calendar, currentDate, style);
}
There should be two instances of this; one at line 398 and one at line 414.
HTH
|
|
|
|
 |
Thank you so much, I really appreciate it, anything I can do like donations or anything let me know?
Justin
modified on Tuesday, November 4, 2008 2:58 PM
|
|
|
|
|
 |
i think t've understand what i want to know. Btw i have question for this sintax, onclick=\"selectDate(" + calendar.name + ", " + currentDate.getUTCDate() + "); " + calendar.name + ".selectEvent('" + eventId + "')\" , what will happen when this sintax operate?
modified on Tuesday, September 16, 2008 5:30 AM
|
|
|
|
 |
I don't understand the question. Could you explain what you mean please?
|
|
|
|
 |
Hi,
I am trying to change the looks of the calendar. Mainly colors...any help as to where i can find the style settings?
|
|
|
|
 |
Hi,
in the sample attached to this article, the styles are defined in the html header - cal_oddweek for the odd numbered weeks of the month, cal_evenweek for even numbered weeks, and so on. You can either replace the values in these classes, or modify the script so it attaches different class names to the elements. The best way to do this is to modify the following lines in the javascript file:
// The css classes for the calendar and header
this.calendarStyle = "cal_calendar";
this.headerStyle = "cal_header";
this.headerCellStyle = "cal_cell";
this.headerCellStyleLabel = "cal_labelcell";
// The css classes for the rows
this.weekStyle = "cal_week";
this.evenWeekStyle = "cal_evenweek";
this.oddWeekStyle = "cal_oddweek";
// The css classes for the day elements
this.dayStyle = "cal_day";
this.disabledDayStyle = "cal_disabled";
this.commonDayStyle = "cal_common";
this.holidayDayStyle = "cal_holiday";
this.eventDayStyle = "cal_event";
this.todayDayStyle = "cal_today";
Hope this helps
|
|
|
|
 |
this is a fine example of a date picker, but if you want a javascript event calendar, check out http://www.scriptcalendar.com
javascript calendar
|
|
|
|
 |
I had to use more than one event and of course for different events different colors.
It was hard to convert your calendar to my project but it worked fine.
thank you for your effort
Ahmet Inan
|
|
|
|
 |
Hi - great calendar, just what I was looking for. I am going to use it for a website I maintain for a Sports bar. However what I am looking for is a way to do an onmouseover control for a date event that changes an image elsewhere on the same page. The image to remain when the mouse moves off the date until another date is "moused over". Maybe in the future also have a separate click event on the date to bring up a separate page.
My problem? I am not a programmer, I just dabble in things enough to get them working and while the above might be easy to do, I am pretty sure it wouldn't be easy for me! So any and all assistance gratefully received.
Thanks again for the code.
|
|
|
|
 |
Hi
This should be pretty simple to do; hooking something of the sort into the onMouseOver for each date should do the trick...
xyz.src = "url of the image";
where xyz is the id of the image you are planning to modify, as in
<img src="default.gif" id="xyz" />
Of course it's not quite that straightforward. For one thing, you'd need to specify the image url somewhere so that the calendar will know what image to load for each date. I'll get back to you on this in a few hours, will hack an example to show you.
The main thing I'd look out for is the ease of use. Having this function fire on mouse over may be a bit tricky to handle for users. Having this work on click might be simpler.
-- modified at 3:41 Thursday 26th January, 2006
|
|
|
|
 |
Replace the RenderDayEvent in the script with the following: -- start of code -- function RenderDayEvent (calendar, currentDate, dayStyle, eventId) { currentDayStyle = dayStyle; calHtml += ('<td class="day">'); calHtml += ("<span class=\"" + dayStyle + "\" onmouseover=\"document.getElementById('calendar_target').src='images/" + currentDate.getUTCFullYear() + "" + (currentDate.getUTCMonth() + 1) + "" + currentDate.getUTCDate() + ".gif'\" onclick=\"selectDate(" + calendar.name + ", " + currentDate.getUTCDate() + "); " + calendar.name + ".selectEvent('" + eventId + "')\">"); calHtml += (currentDate.getUTCDate()); calHtml += ("</span>"); calHtml += ("</td>"); } -- end of code -- Notes: create an image with id "calendar_target" in the page. the days that are marked as events will now change the image. The image will point to a file called "images/[date].gif", where date is the date on fthe given day in the form yyyymdd. So for example the image for today should be saved as "/images/2006126.gif", while one for the 25th December 2006 would be "/images/20061225.gif" Hope this helps
|
|
|
|
 |
That is excellent - works a treat and must have saved me a few days of headaches and googling. Thanks for this and also for the speed of your response, I will post up a link of the finished calendar.
|
|
|
|
|
 |
how we get the source code for genarating calender
|
|
|
|
 |
It's in the zip file linked at the top of this article, no?
|
|
|
|
 |
Hi
could anyone plz help me regarding calender events.....
actually i m using the code provided by "Karl Agius" i am using the code as it is "calender with events" ..but i m unable to understand where i will put my events....and how can i see my events....
Thanks
pragati
pragati
|
|
|
|
 |
Hi there,
The use of events is described in this link:
http://www.codeproject.com/jscript/JavaScriptCalendar.asp?msg=1048881#xx1048881xx[^]
To add the event, you will need to specify a javascript array and set it in the calendar eventDates property. The best place to do this would be just after you define the calendar object and just before you call the render method to display the calendar.
As a side note, you might want to define the events in a separate file and use a server side include to put them in your own page, assuming you're not generating them from your page itself.
Hope this helps,
Karl
|
|
|
|
 |
Hi Karl
thank u very much.........
i really appreciate your help....thanks a ton...
but i have other question....
now my events are hardcoded in an array....wat i m looking for is a text box where i can enter my event on a perticular date....
actually i hv no idea abt script....
plz help me
again thanks
regards,
pragati
|
|
|
|
 |
Hello again Pragati,
No problem
Now, about your question. The answer would depend on what you are using to create your pages. There is no way to create a persistent record using only html and javascript (as far as I know at least) so you'll need some sort of server side script (asp, jsp, php, or whatever). A database of any sort would also be nice, although it is possible to use a file instead and have the script read from and write to it.
The general idea would be to read the events and then use the script to write them. Now, unless you want everyone who visits your page to be able to modify the calendar, you'll also need to have some way to authenticate the user and check that the events entered are valid, and so on. The whole thing would be rather beyond the scope of the calendar itself, so I suggest you look up some other articles in codeproject and then build up your page using them. Feel free to ask if you need any further assistance
Regards,
Karl
|
|
|
|
 |
hi karl
Thanks for guidence
yeah i am also thinking to store my events in database..
nyway thank u very much
Bye
Regards,
pragati
|
|
|
|
 |
hi,
when i display the calendar sample and mouse over any day the cursor changes to cursor:text. But i notice in your style section it's listed as cursor:hand (I'm looking at style class ".cal_day"). Am I not looking at this correctly?
thanks,
rodchar
|
|
|
|
 |
Found it, i think. In the function RenderDayEnabled calHtml += ("<span class=\"" + dayStyle + "\" onclick=\"... dayStyle was missing calendar.dayStyle Would this be a correct assumption? -- modified at 14:32 Wednesday 21st December, 2005
|
|
|
|
 |
It is possible. I believe the hand cursor was only set for days that have an event link, to avoid confusion re. what has an event, and what does not. Will let you know asap.
|
|
|
|
 |
I tried adding it to the .common style attribute and it seem to work pretty good also. I guess it's just a matter of preference.
This is a great calendar thanks for sharing.
|
|
|
|
 |
rodchar wrote: Found it, i think.
In the function RenderDayEnabled
calHtml += ("
dayStyle was missing calendar.dayStyle
Would this be a correct assumption?
I still don't understand about this... I noticed in my calendar, no hand too...
Can you explain again ?? What's wrong (or missing) and how to correct it...
Thanks.
Ditya
|
|
|
|
 |
hey there,
nice calendar, what would i have to do to have a button that will toggle the visibility of the calendar?
thanks,
rodchar
|
|
|
|
 |
Well, the simplest way I can think of, off the top of my head, is to switch the calendar container's display style:
To hide:
document.getElementById('myContainerName').style.display='none';
To display:
document.getElementById('myContainerName').style.display='block';
Let me know if there are any other questions
|
|
|
|
 |
how would you get the calendar to appear over the existing text instead of pushing the text down?
rodchar
|
|
|
|
 |
The simplest way would be to apply an absolute position to the calendar container using css.
Try something like
<div ... style="position:absolute;top:100px;left:100px;">
...
...
</div>
where the div is the calendar container.
-- modified at 5:02 Monday 5th December, 2005
|
|
|
|
|
 |
Hi Karl;
First of all thanks for the sharing your code.
I would like to display different events for different days. However I could not achieve it. Could you please show how to do it?
cal2 = new Calendar ("cal2", "tester2", new Date());
cal2.eventDates = new Array(
new Array("2005/12/2", 1)
,new Array("2005/12/7",2)
);
cal2.scrolling = false;
cal2.selectEvent = function(eventId) {alert("cal2 Event: " + eventId);};
renderCalendar (cal2);
This "cal2 Event: " appears for both date. I would like to have different events on them so
I appreciate it
Thanks
|
|
|
|
 |
I was wondering whether it would be possible to change the background color of some days (of the calendar) based on data retrieved from a text file.
Actually, I have a text file with appr. 100 lines. Each line contains a date (DD/MM/YYYY) and a flag (1,2,3). The two fields are separated by a ";". What I would like to do is to read the text file, load the lines in an array and then use the array to change the background of the days.
I have never used js before (mostly vb, vb.net), but I have read that it is not possible to open and read a file with js.
Is there amother way to read the file, load the array and then use the calendar code to change the backgroud and show the calendar?
Thank you in advance for your time.
Afroditi Pratta.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
|