Click date to make a booking

Help with installation and general calendar setttings

Click date to make a booking

Postby bushidoz » Mon May 17, 2010 9:32 pm

I am trying to customise the calendar so that if someone clicks on an available date it forwards them to a page to book (passing through the date clicked as well).

I've searched the forum and came across a thread where you could make only the available dates clickable and pass the date to a form field, which is half what I want (viewtopic.php?f=22&t=274).

So I now have the available dates clickable, but is there a way for when a date is clicked it opens a new page (eg book.php) and pass through the date clicked?

I hope somebody can help.
bushidoz
 
Posts: 2
Joined: Mon May 17, 2010 9:21 pm

Re: Click date to make a booking

Postby chris » Mon May 17, 2010 9:54 pm

Hi, you should be able to achieve what you want by slghtly adjusting that function on the thread that you mentioned.

For example change the function from this:
Code: Select all
function activate_dates(){
  var dateStart=document.id('date');
  $$('li.clickable').each(function(el){
    if(!el.hasClass('booked')){
      el.addEvent('click',function(){
        dateStart.set('value',this.id);
      }).setStyle('cursor','pointer');
    }
  })
}

to this:
Code: Select all
function activate_dates(){
  var dateStart=document.id('date');
  $$('li.clickable').each(function(el){
    if(!el.hasClass('booked')){
      el.addEvent('click',function(){
        document.location.href='book.php?date='+this.id';
      }).setStyle('cursor','pointer');
    }
  })
}


Is that what you where after?

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Click date to make a booking

Postby bushidoz » Mon May 17, 2010 10:01 pm

That is exactly what I was after! Thanks Chris!
bushidoz
 
Posts: 2
Joined: Mon May 17, 2010 9:21 pm

Re: Click date to make a booking

Postby visnetmedia » Mon Jun 20, 2011 4:17 am

Hi - thanks for the code above but when I put this into the page it removes all the calendar contents - it doesn't like this:
Code: Select all
document.location.href='book.php?date='+this.id';
I am not sure what to change as I want it to go to book.php booking form I will create.

I am also unsure where I am supposed to put this e.g. what file and where:
Code: Select all
    <input type="text" name="dateStart" id="dateStart">



Thanks I don't know javascript...
visnetmedia
 
Posts: 3
Joined: Mon Jun 20, 2011 4:10 am

Re: Click date to make a booking

Postby chris » Mon Jun 20, 2011 8:34 am

Hi,

From the first part of your post I am not sure if there is a question in there.

I am also unsure where I am supposed to put this e.g. what file and where:

Code: Select all
<input type="text" name="dateStart" id="dateStart">

You put that wherever you want it in your document. I would imagine that it would be within the bookings form.

Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: Click date to make a booking

Postby visnetmedia » Tue Jun 21, 2011 6:21 am

Hi Chris

Thanks I thought it would be in a form I build just checking - but the problem is the code

Code: Select all
function activate_dates(){
var dateStart=document.id('date');
$$('li.clickable').each(function(el){
if(!el.hasClass('booked')){
el.addEvent('click',function(){
document.location.href='book.php?date='+this.id';
}).setStyle('cursor','pointer');
}
})
}


When I use this line: document.location.href='book.php?date='+this.id';
it shows no calendar just the border of it no contents. Not sure what to change in that line for it to work...
Thanks
visnetmedia
 
Posts: 3
Joined: Mon Jun 20, 2011 4:10 am

Re: Click date to make a booking

Postby chris » Tue Jun 21, 2011 9:15 am

Hi,
I need to see the full picture of what you are doing.

From the code that you have posted it appears that you are attempting to load a new page when the dates are clicked rather then sending the date to a form field.
Also there are a couple of minor js errors in there which are enough to break the code.
Here is my corrected version (checked and working):
Code: Select all
function activate_dates(){
   var dateStart=document.id('date');
   $$('li.clickable').each(function(el){
      if(!el.hasClass('booked')){
         el.addEvent('click',function(){
            document.location.href='book.php?date='+this.id;
         }).setStyle('cursor','pointer');
      }


Chris


})
}
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain


Return to Support

Who is online

Users browsing this forum: No registered users and 5 guests

cron