[Wolves] Php datepicker calendar - choosing dates

Chris Ellis chris.ellis.intrbiz at googlemail.com
Mon Mar 5 18:51:54 UTC 2012


Hi

On 5 March 2012 16:34, Wayne Morris <waynelists at machx.co.uk> wrote:
> On 05/03/2012 16:11, Chris Ellis wrote:
>>
>> Hi Wayne
>>
>> On 5 March 2012 15:57, Wayne Morris<waynelists at machx.co.uk>  wrote:
>>>
>>> On 05/03/2012 15:44, David Goodwin wrote:
>>>>>
>>>>> Can I overide the disabledays with a 'except these' or do i have to do
>>>>> it
>>>>> some other way?
>>>>> Also, can I add a 'you haven't changed calendar, have another go' else
>>>>> they might just choose default.
>>>>> cheers
>>>>
>>>>
>>>> If I understand your question correctly, you could extend the
>>>> TC_Calendar
>>>> class, and define your own 'disabledDay' function … however, this will
>>>> probably require you to read the source code of the parent (TC_Calendar)
>>>> class and understand how it's working.
>>>>
>>>> David.
>>>> _____________________
>>>
>>> The TC_Calendar function seems to disable an entire column of the
>>> calendar,
>>> so would probably require more fiddling with than I'm capable to
>>> re-enable
>>> only certain dated.
>>> but thanks.
>>
>> Why bother with any PHP, just use a Javascript based date picker.
>> There will be
>> many JQuery based things, a quick Google, for example:
>>
>>     http://jqueryui.com/demos/datepicker/
>>
>> That JQuery based picker, has an event: beforeShowDay which (based on the
>> docs)
>> would allow you to implement what ever day selection logic you need, eg:
>>
>>     $('.selector').datepicker({
>>        beforeShowDay: function(date) { return [ false, 'booked', 'All
>> days are booked!' ]; }
>>     });
>
> I've done nothing with javascript, but done enough to be dangerous with php,
> and needed the calendar function to replace a tedious 'enter your own box'
> on an existing page, where i'd already got the code to submit it in my mysql
> database.

I hope you are using prepared statements and are validating your inputs!

> Didn't want to have to work out how to get the js code to submit
> it, tho that seems easier enough, the js in the datepicker I have is purely
> to pass it over, so seems trivial enough.

The Javascript, simply layers on top of your basic PHP.  The PHP is presumably
creating a text box, to input the date.  The Javascript will just
populate this text box
client side, in the browser.  Submitting that data to you PHP script
would happen in
the same way as your most basic page.

JQuery is good at making Javascript simple.  The following should create the
datepicker for you:

<input type="text" id="date" name="date" value="" />
<script type="text/javascript">
$(document).ready(function(){
    $('#date').datepicker();
});
</script>

>
>> Also, Javascript shares nothing with Java.  They are entirely separate
>> and should
>> never be confused.
>
> i know... since I'd written 'javascript in full at one end of the sentence,
> i figured that people would work out I was being lazy at the other end and
> not typing it in full again ;-)
>
>
>
>> Chris
>
> Thanks, I'll look at that js calendar.
>

Chris



More information about the Wolves mailing list