Jump to content

refresh calendar without refreshing whole page


clausowitz

Recommended Posts

Hi All,

I have a month calendar on my homepage I want to be able to refresh it when the user clicks next month or last month with AJAX.

That way not the whole page gets refreshed. When the user clicks next month there will normally be a php POST with a variable that gives the date like for example:

index.php?date=1313013600. That should be given with the AJAX code I believe.

 

<?php if(!isset($_REQUEST['date'])){ 
   $date = mktime(0, 0, 0, date('m'),  date('d'),  date('Y')); 
} else { 
   $date = $_REQUEST['date']; 
} 

// Build Previous and Next Links 
$previous_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
if($month == 1){ 
   $previous_link .= mktime(0, 0, 0, 12, $day, ($year -1)); 
} else { 
   $previous_link .= mktime(0, 0, 0, ($month -1), $day, $year); 
} 
$previous_link .= "\"><< Prev</a>"; 

$next_link = "<a href=\"".$_SERVER['PHP_SELF']."?date="; 
if($month == 12){ 
   $next_link .= mktime(0, 0, 0, 1, $day, ($year + 1)); 
} else { 
   $next_link .= mktime(0, 0, 0, ($month +1), $day, $year); 
} 
$next_link .= "\">Next >></a>"; ?> 

 

Is there anyone who knows how to do this? This is my first AJAX experience.

Marco

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.