It's a little confusing as to what you are trying to do here.  Are you
trying to suppress dates within certain ranges?  If so, you could move
your natDays array out to a global area.  This is not required but
would help so that you are not re-declaring it for every day of the
calendar.

The real issue is caused by the fact that you are exiting your loop of
the date array on the first cycle, because you return false or true
based on the _first_ comparison.  You would want to do something like
this to ensure that you loop through all the ranges in your array.


for (var i=0, c=natDays.length; i<c; i++)
{
   if (dat >= natDays[i][0] && dat<=natDays[i][1]) return [false, ""];
}
return [true, "2"];


Hth,

Dave



On Oct 3, 2:50 pm, Wudang123 <[email protected]> wrote:
>  Trying to get this code working, it makes the first dates in the
> array non.selectable, but the rest wont work as planned, any
> suggestions?
>
> beforeShowDay:function(d) {
>       var dat = $.datepicker.formatDate("yy-mm-dd", d);
> natDays = [
>   ["2009-10-15","2009-10-20"],
>   ["2009-10-22","2009-10-31"],
>   ["2009-11-01","2009-11-15"]
> ];
>
> for (var i=0, c=natDays.length; i<c; i++)
>  if (dat >= natDays[i][0] && dat<=natDays[i][1])
>   {return [false, ""];
>
>         }
> else  {return [true, "2"];    }
>
>           }
>
> On 7 Sep, 00:50, Fontzter <[email protected]> wrote:
>
> > Just set the start date from your database as the minDate for 
> > thedatepickerand set the end date as the maxDate.
>
> > Dave
>
> > On Sep 6, 11:44 am, Wudang123 <[email protected]> wrote:
>
> > > Wonderful, almost worked exaclty as I wanted it to.
>
> > >  The dates are saved in a database, one field named startDate, and one
> > > endDate
>
> > >  For example, if the start date is 2009-10-12, and the end date is
> > > 2009-10-20, are there a easy way to let the script parse through all
> > > the dates between start date and end date?
>
> > > On 1 Sep, 22:47, Fontzter <[email protected]> wrote:
>
> > > > Here ya go:http://jsbin.com/ezomu/edit
>
> > > > If the dates are contiguous, min and max date works best.
>
> > > > Hth,
>
> > > > Dave
>
> > > > On Sep 1, 4:04 pm, Wudang123 <[email protected]> wrote:
>
> > > > > Hi,
>
> > > > >  Working on a booking form, and I want a function to check if dates
> > > > > are available for booking.
> > > > >  Seen some examples, but can´t get it right.
>
> > > > >  I´m looking for a function that check a range of dates(eg, 2009-10-12
> > > > > to 2009-11-10) and then set them available or not.
>
> > > > >  Any suggestions on a function that can do that?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to