Click here to Skip to main content
15,888,065 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: So I rewrote the program from scratch, works pretty good now, feel free to build on it Pin
Richard MacCutchan20-Dec-12 6:39
mveRichard MacCutchan20-Dec-12 6:39 
QuestionJava Script Pin
manoj s sherje14-Dec-12 1:05
manoj s sherje14-Dec-12 1:05 
QuestionRe: Java Script Pin
Thomas Daniels14-Dec-12 1:33
mentorThomas Daniels14-Dec-12 1:33 
QuestionRe: Java Script Pin
ZurdoDev18-Dec-12 5:06
professionalZurdoDev18-Dec-12 5:06 
AnswerRe: Java Script Pin
manoj s sherje19-Dec-12 1:01
manoj s sherje19-Dec-12 1:01 
AnswerRe: Java Script Pin
ZurdoDev19-Dec-12 1:37
professionalZurdoDev19-Dec-12 1:37 
AnswerRe: Java Script Pin
vbmike19-Dec-12 4:28
vbmike19-Dec-12 4:28 
QuestionUsing datePicker to disable dates already selected Pin
xnaLearner11-Dec-12 3:39
xnaLearner11-Dec-12 3:39 
hey guys..So I am using datepicker http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerStartEnd.htmlto select start and end dates.I have the controller coded so that if the user attempts to select a date from the calendar (which is already stored for them-from a previous selection) it will not add it to the DB. I also have the weekends blocked out so they cant be used (done using
http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellRender.html)

E.g say the user has previously selected fri 14th and added it to the DB, if they try to make a new record selecting from thur 13th to mon 17th- only thur 13, and mon 17th will be added to the DB. As fri 14th was previously added and 15 and 16th are weekendsone using the following code:
C#
[HttpPost] public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate, string AlreadyExists) 
{ DateTime startDates = Convert.ToDateTime(HolidayDate); 
DateTime endDates = Convert.ToDateTime(endDate); 

while (startDates <= endDates)
{
if (startDates.DayOfWeek != DayOfWeek.Saturday && startDates.DayOfWeek != DayOfWeek.Sunday)
{ 
ViewBag.CantDuplicateHolidays = String.IsNullOrEmpty(AlreadyExists) ? "date" : "";
var dates = from d in db.Holidays
where d.HolidayDate == startDates && d.PersonId == PersonId
select d;


// <= 0..so if it does not already exist
if (dates.Count() <= 0)
{
Holiday holiday1 = new Holiday();
holiday1.PersonId = PersonId.Value;
holiday1.HolidayDate = startDates;


db.Holidays.AddObject(holiday1);
db.SaveChanges();
//say start date is 10. AddDays(1) will make it 11 then return it to startDates in 'startDates' = startdates,
//but doesnt chage the value of startdates = 'startdates'
}


}


startDates = startDates.AddDays(1);
}


return RedirectToAction("Index");
}

---------------
my view
HTML
Date.format = 'dd/m/yyy';
$("#HolidayDate").addClass('date-pick');
$("#endDate").addClass('date-pick');
//$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();


// clickInput: true


$(function () {
//3 methods below dont allow user to select weekends
$('.date-pick').datePicker(
{
createButton: false,
renderCallback: function ($td, thisDate, month, year) {
if (thisDate.isWeekend()) {
$td.addClass('weekend');
$td.addClass('disabled');
}


}
}
)


.bind('click',
function () {
$(this).dpDisplay();
this.blur();
return false;
}
)


.bind('dateSelected',
function (e, selectedDate, $td) {
console.log('You selected ' + selectedDate);
}
);


// HolidayDate is start date
$('#HolidayDate').bind('dpClosed',
function (e, selectedDates) {
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#endDate').dpSetStartDate(d.addDays(0).asString());
}
}
);


//end date is end date
$('#endDate').bind('dpClosed',
function (e, selectedDates) {
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#HolidayDate').dpSetEndDate(d.addDays(0).asString());
}
}
);
});



can any suggest how to disable a date on the calendar if it is already in the DB
Questionjquery tabslideout plugin and wired behavior Pin
Tridip Bhattacharjee9-Dec-12 21:13
professionalTridip Bhattacharjee9-Dec-12 21:13 
AnswerRe: jquery tabslideout plugin and wired behavior Pin
Mayor Daily17-Dec-12 4:22
Mayor Daily17-Dec-12 4:22 
GeneralRe: jquery tabslideout plugin and wired behavior Pin
Tridip Bhattacharjee18-Dec-12 0:55
professionalTridip Bhattacharjee18-Dec-12 0:55 
QuestionNeed help understanding binding Pin
Steve Bondy7-Dec-12 14:00
Steve Bondy7-Dec-12 14:00 
QuestionText replace Pin
rakeshs3126-Dec-12 23:06
rakeshs3126-Dec-12 23:06 
AnswerRe: Text replace Pin
Richard MacCutchan7-Dec-12 0:43
mveRichard MacCutchan7-Dec-12 0:43 
GeneralRe: Text replace Pin
rakeshs3129-Dec-12 5:40
rakeshs3129-Dec-12 5:40 
QuestionJQuery datePicker SelectMultiple format dd/mm/yy Pin
xnaLearner6-Dec-12 0:37
xnaLearner6-Dec-12 0:37 
AnswerRe: JQuery datePicker SelectMultiple format dd/mm/yy Pin
srinivas nv6-Dec-12 21:50
srinivas nv6-Dec-12 21:50 
GeneralRe: JQuery datePicker SelectMultiple format dd/mm/yy Pin
xnaLearner10-Dec-12 0:04
xnaLearner10-Dec-12 0:04 
QuestionDelete selected rows by table id using javascript Pin
Member 88023075-Dec-12 8:05
Member 88023075-Dec-12 8:05 
AnswerRe: Delete selected rows by table id using javascript Pin
Deepak Kr15-Dec-12 18:45
Deepak Kr15-Dec-12 18:45 
GeneralRe: Delete selected rows by table id using javascript Pin
Member 88023076-Dec-12 6:20
Member 88023076-Dec-12 6:20 
AnswerRe: Delete selected rows by table id using javascript Pin
Graham Breach6-Dec-12 21:41
Graham Breach6-Dec-12 21:41 
QuestionHTML5 Javascript Issue Pin
#realJSOP3-Dec-12 1:09
mve#realJSOP3-Dec-12 1:09 
AnswerRe: HTML5 Javascript Issue Pin
Graham Breach3-Dec-12 5:00
Graham Breach3-Dec-12 5:00 
GeneralRe: HTML5 Javascript Issue Pin
#realJSOP3-Dec-12 5:22
mve#realJSOP3-Dec-12 5:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.