How to create calendar without weekends?

Asked By 30 points N/A Posted on -
qa-featured


Hi techyv,


How to create calendar without weekends? I am using java programming language to create my own organizer; I don’t want to include weekends for all I want to record are events which is for weekdays. Tell me about the process and discuss some terms to be considered.
Hoping for your help. Thanks.

SHARE
Best Answer by Aust Wilson
Best Answer
Best Answer
Answered By 5 points N/A #178625

How to create calendar without weekends?

qa-featured

You can use JQuery Datepicker Ul. This is the sample formula to disable weekends.

$(function() {
$(‘#id’).datepicker({
beforeShowDay: $.datepicker.noWeekends
});
});

Check it out in this site:

https://stackoverflow.com/questions/11337720/datepicker-like-jquery-calendar-without-weekends

The sample is also taken from the same site.

Here’s another possibility:

First, modify your calendar settings.
Change the “First day of week” as Monday, moving Saturday and Sunday to the last columns.

In your page, add a CEWP under the calendar and put the script below in the link.

<script type=”text/javascript”>
02    //
03    // Calendar – Weekdays only
04    // Questions and comments: [email protected]
05    //
06    // Regional settings: week starts on Monday.
07    // Change the CalendarWidth value to adjust the width of the calendar.
08    // 742 pixels is the default SharePoint value.
09    // Set the value to zero for automatic layout.
10    //
11
12    var CalendarWidth = 742;
13
14    var theCalTable = document.getElementById(“CalViewTable1”);
15    if (theCalTable != null)
16    {
17    theCalTable.rows[0].cells[0].getElementsByTagName(“IMG”)[0].width = CalendarWidth;
18
19    // Number of columns to remove
20    var ColCount = 0;
21    switch (theCalTable.parentNode.id)
22    {
23    case “MontlyViewDefault_CalendarView”:
24      ColCount = 2;
25    break;
26    case “WeeklyViewDefault_CalendarView”:
27      ColCount = 6;
28    break;
29    }
30
31    var theCalendar = theCalTable.rows[2].cells[0].firstChild ;
32    if (theCalendar.nodeType!=1) {theCalendar = GetFirstChildElement(theCalTable.rows[2].cells[0]);} // for Firefox
33
34    for (var i=0; i
35    <theCalendar.rows.length; i++)
36    {
37    var imax=0;
38    do {
39    var lastchild = theCalendar.rows[i].lastChild ;
40    if (lastchild.nodeType!=1) {theCalendar.rows[i].removeChild(lastchild); continue;} // for Firefox
41    if ((lastchild.className == “ms-cal-week”) || (lastchild.className == “ms-cal-weekB”)) {break;}
42    imax = imax + lastchild.colSpan;
43    if (imax <= ColCount) {
44    theCalendar.rows[i].removeChild(lastchild);
45    }
46    } while (imax < ColCount)
47    }
48    }
49    </script>
50    <style type=”text/css”>
51    .ms-cal-weekname {width:20%;}
52    </style>

This script removes the columns of Saturday and Sunday. It works well for the month and week view.

Just remember to adjust the “CalendarWidth,” setting it to zero for automatic layout.

If you include weekend events, then the script won’t work.

You may also try the link below to disable specified days:

jQuery UI DatePicker: Disable Specified Days

This is also found on the same site mentioned above.

Answered By 5 points N/A #178626

How to create calendar without weekends?

qa-featured

I have an easier solution. You could use the google calendar. You just have to check the days that you need to show up and make it repeated. If sometime you want a weekend for any reason to show up again you can just stop the repeated process and manually check the days that you need.

Related Questions