Thanks Blair. 

I have it nearly working correctly just one hiccup when you select the
arrivaldate that is greater than the first date it highlights from the
beginning to the departure date, though if you select again without clearing
fields it works correctly. 



my code
------------------------------------------------------------------------------
        var arrivaldate=false;
        var departuredate=false;
        var $dates=$(".apt td").not(".past");
        var $range = false; // deliberately select no elements  
        
        $dates.click( function() {
                if ($("[EMAIL PROTECTED]").val() != '') {
                        if (compareDates($("[EMAIL 
PROTECTED]").val(),'yyyy-M-d',
this.title,'yyyy-M-d' ) || this.title == $("[EMAIL PROTECTED]").val()) {
                                var $range=false; // deliberately select no 
elements                                                    
                                arrivaldate=this;
                                departuredate=null;                     
                                $(".apt td").removeClass("selected");
                                $("[EMAIL PROTECTED]").val(''); 
                        } else {
                                departuredate=this;                             
                                var 
$range=$($dates).lt($dates.index(departuredate)+1);
                                $range=$range.gt($dates.index(arrivaldate)-1);  
                                                        
                                $("[EMAIL 
PROTECTED]").val(departuredate.title);  
                        }
                        $("[EMAIL PROTECTED]").val(arrivaldate.title); 
                        $(arrivaldate).addClass("selected");                    
                 
                } else {
                        arrivaldate=this.title;
                        departuredate=null;
                        $(arrivaldate).addClass("selected");                    
                        $("[EMAIL PROTECTED]").val(arrivaldate); 
                        $("div.message h3").html('Please Select Departure 
Date');
                }

                if ($range) {
                        $(".apt td").removeClass("selected");   
                        $($range).addClass("selected");                         
                        
                } else {
                        $(".apt td").removeClass("selected");                   
                        
                }

        });
-----------------------------------------------------------------------------------

Blair McKenzie-2 wrote:
> 
> // declare dates here for access by all events
> var firstdateel=false;
> var lastdateel=false;
> 
> // or you could select hidden input elements and use those
> var $firstdate = $("input");
> var $lastdate = $("input");
> 
> // select all dates
> var $dates=$("td.selectabledate");
> // declare the range variable for access by all events
> var $range=$("noelements"); // deliberately select no elements
> 
> // attach the click event
> $dates.click(function(){
>    // if firstdateel is unset or lastdateel is set, then start a new range
>    if (!firstdateel || lastdateel) {
>       firstdateel=this;
>       lastdateel=null;
>       // Do stuff to previous $range (if there was a previous selection,
> you'll probably want to unhighlight it before resetting it)
>       $range=$("noelements");
>       // Starting new date range, do stuff to update ui
>    }
>    else {
>       lastdateel=this;
>       var $range=$($dates).lt($dates.index(lastdateel)+1); // filter out
> dates after the last one
>       $range=$range.gt($dates.index(firstdateel)-1); // filter out dates
> before first one
>       // Finished selecting range, do stuff to update ui
>    }
> });
> 
> Blair
> 
> On 12/14/06, mylocal <[EMAIL PROTECTED]> wrote:
>>
>>
>> I have been trying to do a inline calendar for a client where you select
>> the
>> arrival date and then departure date and once the second click is
>> registered
>> in gives me an array of elemets between the two depending on class and
>> highlights those spaces if there available.
>>
>> some code here at present : http://clients.ozdesign.com/104/book.php
>>
>> This is a work in progress, whilst trying to understand jquery more.
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Select-All-elements-between-clicks--need-help-please-tf2817436.html#a7863807
>> Sent from the JQuery mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>>
> 
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Select-All-elements-between-clicks--need-help-please-tf2817436.html#a7867661
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to