Hi folks,
Too many edits to keep track of, but I have simplified the issue. I have this code in my index.php:
<div class="calendar_top">
<?php
include(SITE_ROOT . "/includes/sub_top_divs.php"); ?>
</div>
<table class="tablebodycontainer"><tr><td>
<?php
include(SITE_ROOT . "/includes/view-monthly-calendar-ajax.php");
?>
</td></tr></table>
<?php include(SITE_ROOT . "/includes/copyright.php"); ?>
</div>
The subtop above contains the navigation links:
includes/subtop-divs.php:
<?php
//include(SITE_ROOT . "/includes/set-variables.php");//dateFormat($date)
echo "<table class='navtabs' cellpadding='0' cellspacing='0'>";
echo "<tr><td class='right'>";
echo buildMenuNavigation($currentPageIndex);
echo '</td></tr></table>';
?>
Here is that buildMenuNavigation function:
function buildMenuNavigation($currentIndex=0) {
$navtabs = array(
'0'=>array('Monthly'=>'index.php'),
'1'=>array('Daily'=>'agenda.php'),
'2'=>array('Admin'=>'admin/view-timelines.php'),
'3'=>array('Help'=>'help.php'),
);
$sep = '<li> | </li>';$builtNav=array();
foreach($navtabs as $index=>$tablinks) {
foreach($tablinks as $key=>$value) {
$class='';
if($index==$currentIndex) {
$class=' class="selected"';
}
//pr($value);
$builtNav[] = '<li><a href="' . SITE_URL . '/' . $value.'"' . $class .'> '.$key.' </a></li>';
}
}
return '<ul>' . implode($sep,$builtNav) . '</ul>';
}
The only data that actually changes when switching pages is the contents in the above:
<?php
include(SITE_ROOT . "/includes/view-monthly-calendar-ajax.php");
?>
So this seems like a perfect candidate for ajax.
Here is the contents of /includes/view-monthly-calendar-ajax.php:
<?php
$counter = 0;
?>
<table class="tabbody">
<tr>
<td class='head unselectable'>Sun</td>
<td class='head unselectable'>Mon</td>
<td class='head unselectable'>Tue</td>
<td class='head unselectable'>Wed</td>
<td class='head unselectable'>Thu</td>
<td class='head unselectable'>Fri</td>
<td class='head unselectable'>Sat</td>
</tr>
<tr>
<?php
//echo $year."-".$month."-";
$flag = 0;
$daysInrow = 0;
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$daysInrow++;
$zero = "";
if($i < 10)
{
$zero = "0";
}
$t_date = $year."-".$month."-".$zero.$i;
//$t_date = "$year-$month-$i";
$timeStamp = strtotime($t_date);
$eventID = 0;
$eventName = " ";
$bgColor = "";
$funcBG = "setbgcolorMonth($i);";
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++)
echo "<td class='tddaybox'></td>";
}
if($counter % 7 == 0)
{
$daysInrow = 1;
echo "</tr><tr>";
}
if(date("w", $timeStamp) == 0)
if($i == date("d") && $month == date("m") && $year == date("Y"))
$class = "class='today'";
else
$class = "class='weekend'";
else
if($i == date("d") && $month == date("m") && $year == date("Y"))
$class = "class='today'";
else
$class = "class='normal'";
$numric_time = getNumericTime($_SESSION['userData']['timezone']);//Get the numeric timezone
$query = "SELECT * FROM events WHERE date(convert_tz(StartDate,'+00:00','". $numric_time."'))='".$t_date."' AND UserID='" . $_SESSION['userData']['UserID'] ."' ORDER BY PTLType ASC";
//br();
$result = mysql_query($query);
if(mysql_num_rows($result))//cursor:hand;cursor:pointer;width:112px;
{
$funcBG = "";
echo "<td valign='top' class='a_cursor_width tddaybox' id='day$i' onclick='setbgcolorMonth($i)'>";
echo "<div class='td_overlow'>";
echo '<table style="width:100%;border:0;">';
echo '<tr class="rowColor"><td '.$class.'><div class="div_left"><a href="'.SITE_URL.'/agenda.php?date='.$year.'-'.$month.'-'.$zero.$i.'">'.$i.'</a></div><div class="div_left_80" onclick="'.$funcBG.' get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false"> </div></td></tr>';
while($row = mysql_fetch_assoc($result))
{
$eventID = $row['EventID'];
$parentEventID = $row['ParentEventID'];
$eventName = stripslashes($row['EventName']);
$PTLType = $row['PTLType'];
$textclass = "title4";
$onclick_call = 'get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\')';
if($PTLType != 0) {
$onclick_call = 'get_event_popup(window.event, this, \''.SITE_URL.'/timeline-popup.php\', \'eventID='.$eventID.'\', \'parentEventID='.$parentEventID.'\', \'type=M\')';
$bgColor = "";
$textclass = "redtext";
if($PTLType == 3) {
$textclass = "bluetext";
$display = "none";
} else {
$display = "block";
}
$event_name_wrapped = '<div>'.$eventName.'</div>';
} else {
$textclass = "mainEvent";
$display = "block";
$event_name_wrapped = '<div>'.$eventName.'</div>';
}
echo '<tr><td onclick="'.$onclick_call.';return false;" class="'.$textclass.' a_cursor" title="'.$eventName.'" style="display:'.$display.';">'.$event_name_wrapped.'</td></tr>';
}
echo '<tr><td onclick="get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID=0\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false;" class="a_cursor"> </td></tr>';
echo "</table>";
echo "</div>";
echo "</td>";
}
else
{
echo '<td id="day'.$i.'" height="80" valign="top" onclick="'.$funcBG.' get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false;" class="tddaybox a_cursor">';
echo '<table style="width:100%;">';
echo "<tr class='rowColor'><td $class>$i</td></tr>";
echo "<tr><td> </td></tr>";
echo "</table>";
echo "</td>";
}
}
for($l=0;$l<7-$daysInrow;$l++)
{
echo "<td class='tddaybox'> </td>";
}
?>
</tr>
</table>
<?php
/*
if(isset($divRed))
{
$divRed = implode(",",$divRed);
echo "<div id='divRed1' style='display:none'>$divRed</div>";
}
else
{
echo "<div id='divRed1' style='display:none'>0</div>";
}
if(isset($divBlue))
{
$divBlue= implode(",",$divBlue);
echo "<div id='divBlue1' style='display:none'>$divBlue</div>";
}
else
{
echo "<div id='divBlue1' style='display:none'>0</div>";
}
if(isset($divMainEvent))
{
$divMainEvent= implode(",",$divMainEvent);
echo "<div id='divMainEvent1' style='display:none'>$divMainEvent</div>";
}
else
{
echo "<div id='divMainEvent1' style='display:none'>0</div>";
}
*/
?>
<div id='gig1' style='display:none'>0</div>
<div id='todo1' style='display:none'>0</div>
<div id='completed1' style='display:none'>1</div>
<input type="hidden" id='lastselectedday' value='' />
So the output for all of the above is correct now, but when I try and do this:
<form>
<input type="button" value="Display Message" onclick="getData('/Dev2/includes/view-monthly-calendar-ajax.php', 'targetDiv')">
</form>
<table class="tablebodycontainer">
<tr>
<td id="MainCalendarContainer">
<div class="ajaxswap" id="targetDiv">
</div>
The output of the ajax call doesn't execute the php.