brad_langdon Posted November 4, 2009 Share Posted November 4, 2009 Can anyone tell me how to use a jquery date picker in a way that it checks whether or not the selected date is available? So basically if a date is not available it would gray out the unavailable dates or something similar. I want to use it for a booking system but I am not sure how to do this part. I guess it would have to fetch the info from a database or could it all be done somehow in the javascript file? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/180325-date-picker-to-check-availability/ Share on other sites More sharing options...
jcombs_31 Posted November 5, 2009 Share Posted November 5, 2009 Typically a date picker does not have the functionality you want, it will simply allow you to choose a date from a calendar and then submit that to be checked on the server side. You could I'm sure add the functionality of disabling dates but you would have to tie that into an ajax call and it could get complex. Is it not easier to just them first select the date and then submit it for a check? Doing that is rather simple because the datepicker is simply going to give your text in date format that you can easily check with php and then give the user feedback. Or you can have a reponse area and do an ajax call that says if that date is available or not. This way you still get an immediate response but don't have to edit the calendar code. Quote Link to comment https://forums.phpfreaks.com/topic/180325-date-picker-to-check-availability/#findComment-951735 Share on other sites More sharing options...
JustLikeIcarus Posted November 12, 2009 Share Posted November 12, 2009 Here is how i did it in the past. The disableDays function you see being called basically looks at the current date to see if its available. The reportForm2.html is backend script that returns a JSON object of all available days. $.getJSON("reportForm2.html", {id: itemId}, function(data, textStatus) { global = data; $('#fromDate, #toDate').datepicker({ dateFormat: 'mm/dd/yy', showOn: "button", buttonImage: "images/icons/calendar.png", buttonImageOnly: true, changeYear: true, changeMonth: true, duration:0, showButtonPanel: true , beforeShowDay: disableDays }); }); Quote Link to comment https://forums.phpfreaks.com/topic/180325-date-picker-to-check-availability/#findComment-956362 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.