I'm not sure if this has been covered before so I'll explain.
With the help of some of the posts on this forum, I was able to create a calendar that could be used to book single days.
Now I am looking to book several days at a time. In practice the user would choose their start date (by clicking the appropriate day). After this I'd like to show a dropdown menu based on the number of days they can book (according to what's available on the calendar).
This would be achieved by querying the database using ajax when the user clicks a date.
To boil it all down - is it possible to send an ajax request on clicking one of the dates and for the value of that date (e.g. 2013-05-20) to be sent in the request?
I've tried to add in various lines in the code below but to no avail.
mootools-cal-public.js
- Code: Select all
// make the dates clickable
function activate_dates(){
var date=document.getElementById('date');
$$('li.clickable').each(function(el){
if(el.hasClass('available')){
el.addEvent('click',function(){
alert('clicked!');
// Set the date in the date input (hidden)
date.set('value',this.id);
// Test alert (returns nothing)
alert('Clicked!');
//Animate the background colour and show the booking button
$(this).animate({ backgroundColor: "#BAE39F" }, "500").animate({backgroundColor:"green" }, 500);
$('#booking_submit').fadeOut(500).fadeIn(300);
//Hide the unavailable button if it is showing
$('.date-booked').hide();
}).setStyle('cursor','pointer');
} else if (el.hasClass('booked')){
el.addEvent('click',function(){
$('#booking_submit').hide();
$('.date-booked').show();
$('.date-booked').animate({ backgroundColor: "#ffae00 " }, "500").animate({backgroundColor:"#f00" }, 500);
}).setStyle('cursor','pointer');
}
})
}
Thanks,
Chris