how to send the date on different pages.

Help with installation and general calendar setttings

how to send the date on different pages.

Postby amit » Thu May 20, 2010 2:19 pm

hello sir,

Actually i am using the function active_dates() ...in mootools-cal-public.js file
like this
Code: Select all
function activate_dates(){
   //    add custom events here - eg to update booking form
   var dateStart=document.id('date_start');
   
   //   event delegation method - requires "more" file
   document.id('the_months').addEvent('click:relay(.clickable)',function()
   {
      if(!this.hasClass('booked'))
      {
         dateStart.set('value',this.id);
       }
   });
   
   
 
   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');
    }
  })
 
}


in this function it is sending the page to url book.php with particular date:- document.location.href='book.php?date='+this.id;


But the thing which i want i want to send the page to different url for every catagory for which calendar is selected.
for example if it is showing three hotel room catagories ..like
1.Deluxe //should go to book1.php
2.Executive //should go to book2.php
3.Premium //should go to book3.php

Is it possible to create such a function so that it can redirect it to different pages.



regards
amit
amit
 
Posts: 8
Joined: Wed May 19, 2010 11:35 am

Re: how to send the date on different pages.

Postby chris » Thu May 20, 2010 2:26 pm

So, do you have something like a select list with these categories?

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

Re: how to send the date on different pages.

Postby amit » Fri May 21, 2010 7:27 am

hello sir,
Thanks for your concern.
Actually i am using booking item drop down to select a catagory (ex. in booking item drop down there are 3 catagories like deluxe,premium and excutive).
So when a user selects a catagory from the booking item drop down list....he must be redirected to different url each time..
like..
for item1(deluxe catagory) //it should go to book1.php page with the date value
item 2(premium catagory) //it should go to book2.php page with the date value
item 3(executive catagory) // it should go to book3.php page with the date value.


now i think you get my point sir :P


regards
amit :geek:
amit
 
Posts: 8
Joined: Wed May 19, 2010 11:35 am

Re: how to send the date on different pages.

Postby chris » Fri May 21, 2010 8:13 am

Hellom
What I am trying to find out is if, on the form where the calendar is shown, if the user can choose this category or if it has already been selected on a previous page.

I need to understand this to be able to show you the code that you neeed to add/modify to be able to redirect your form accordingly.

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

Re: how to send the date on different pages.

Postby amit » Fri May 21, 2010 11:05 am

hello sir,


by chris » Fri May 21, 2010 8:13 am
What I am trying to find out is if, on the form where the calendar is shown, if the user can choose this category or if it has already been selected on a previous page.


Actually i will alow user to choose a catagory on the same page where the calendar is shown...through the dropdown which is used by you for items in demo.
I mean these catagories should b editable through "Booking items" by the admin like items.



regards
amit
amit
 
Posts: 8
Joined: Wed May 19, 2010 11:35 am

Re: how to send the date on different pages.

Postby chris » Fri May 21, 2010 11:33 am

Right, so you have a select list of these categories on the page where the user can click on the dates.

Understanding that is important, otherwise I don't know how to help you. Ideally a demo url is always the best and quickest way to get help as that way I can see exactly what you currently have.

So, as to your request....
You currently have this:
Code: Select all
$$('li.clickable').each(function(el){
     if(!el.hasClass('booked')){
       el.addEvent('click',function(){
         document.location.href='book.php?date='+this.id;
      }).setStyle('cursor','pointer');
    }
  })

You need to extend that to get the currently selected id of your "categories" select list.
First, make sure that your categories select list has an id, eg "id_cat"
Than, get the currently selected value by adding this line of code to the function:
Code: Select all
var id_cat=document.id('id_cat').get('value'));

Finally you use this new variable to decide which page to show for example like this:
Code: Select all
var url='book'+id_cat+'.php';


Putting that all together you would have this:
Code: Select all
$$('li.clickable').each(function(el){
  if(!el.hasClass('booked')){
    el.addEvent('click',function(){
      var id_cat=document.id('id_cat').get('value'));
      var url='book'+id_cat+'.php';
      document.location.href=''+url+'?date='+this.id;
    }).setStyle('cursor','pointer');
  }
})

Now, clearly that code "assumes" that your id categories are "1", "2" and "3" which might not be the case.
If they are not, you will have to adjust that code slightly either with a javascript array or with a siwtch or "if" clause to identify which url to show according to the category selected.
Hopefully though I have shown you enough to set you on your way :)

Chris
PS. I must say that personally I wouldn't have thought that having a seperate booking page for each category is not very optimal. However clearly I don't know all the details of your project ;)
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Re: how to send the date on different pages.

Postby amit » Fri May 21, 2010 11:48 am

Thanks Sir,


For yor concern and the way you told me everything ..step by step :P :P

Anyways if i stucked somewhere i will get to u again. :mrgreen: ..now i am going for that..
Thanks again..have a wonderful day :P .




regards
amit :mrgreen:
amit
 
Posts: 8
Joined: Wed May 19, 2010 11:35 am


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron