I downloaded this calendar off the web and am trying have it show twice, once as calendar.php and the second time as calendar1.php
I need the visitor to be able to select a beginning date and an ending date. Here is the primary page that I have -
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
<title>Your Title</title>
-
<link rel="stylesheet" type="text/css" href="calendar_style.css">
-
<script type="text/javascript">
-
var req;
-
-
function navigate(month,year) {
-
var url = "calendar.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type="text/javascript">
-
var req;
-
-
function navigate1(month,year) {
-
var url = "calendar1.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback1() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type="text/javascript">
-
function init()
-
-
{
-
navigate("","");
-
navigate1("","");
-
}
-
//-->
-
</script>
-
</head>
-
<body onLoad="init()">
-
<div id="calendar" style="margin-top: 20px;margin-bottom: 20px"></div>
-
-
</body>
-
</html>
-
And here is the AJAX Calendar -
<?
-
-
$output = '';
-
-
if($_GET[month] == '' && $$_GET[year] == '') {
-
$time = time();
-
$month = date('n',$time);
-
$year = date('Y',$time);
-
}
-
-
$date = getdate(mktime(0,0,0,$month,1,$year));
-
$today = getdate();
-
$hours = $today[hours];
-
$mins = $today[minutes];
-
$secs = $today[seconds];
-
-
if(strlen($hours)<2) $hours="0".$hours;
-
if(strlen($mins)<2) $mins="0".$mins;
-
if(strlen($secs)<2) $secs="0".$secs;
-
-
$days=date("t",mktime(0,0,0,$month,1,$year));
-
$start = $date[wday]+1;
-
$name = $date[month];
-
$year2 = $date[year];
-
$offset = $days + $start - 1;
-
-
if($month==12) {
-
$next=1;
-
$nexty=$year + 1;
-
} else {
-
$next=$month + 1;
-
$nexty=$year;
-
}
-
-
if($month==1) {
-
$prev=12;
-
$prevy=$year - 1;
-
} else {
-
$prev=$month - 1;
-
$prevy=$year;
-
}
-
-
if($offset <= 28) $weeks=28;
-
elseif($offset > 35) $weeks = 42;
-
else $weeks = 35;
-
-
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
-
<tr>
-
<td colspan='7'>
-
<table border='0' width='100%'>
-
<tr>
-
<td valign='middle'>
-
<a href='javascript:navigate($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate($next,$nexty)'><img src='right.gif' border='0'></a>
-
</td>
-
<td align='right'>
-
<div id='heading'>$name $year2</div>
-
</td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td class='dayhead'>Sun</td>
-
<td class='dayhead'>Mon</td>
-
<td class='dayhead'>Tue</td>
-
<td class='dayhead'>Wed</td>
-
<td class='dayhead'>Thu</td>
-
<td class='dayhead'>Fri</td>
-
<td class='dayhead'>Sat</td>
-
</tr>";
-
-
$col=1;
-
$cur=1;
-
$next=0;
-
-
for($i=1;$i<=$weeks;$i++) {
-
if($next==3) $next=0;
-
if($col==1) $output.="<tr class='dayrow'>";
-
-
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
-
-
if($i <= ($days+($start-1)) && $i >= $start) {
-
$output.="<div";
-
-
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
-
$output.="><b>$cur</b>";
-
-
$output.="</div></td>";
-
$cur++;
-
$col++;
-
} else {
-
$output.=" </td>";
-
$col++;
-
}
-
-
if($col==8) {
-
$output.="</tr>";
-
$col=1;
-
}
-
}
-
-
$output.="</table>";
-
-
echo $output;
-
-
?>
-
All I did is name calendar.php to calendar1.php and copied and changed the function.
somehow or another I am lost in what I did and appreciate any help to get both calendars to display at the same time and they will both have different outputs.
An arrival time and a departure time.
Thanks in Advance
12 3383
the page is located at http://www.reserveitnow.us/calendar1/ajax_calendar.php
Using more than 1 XMLRequest is a drag. To be compatible all around you need to do only 1 request per request object then destroy the old one and make a new. It is stupid, I know, but that's where ajax is at. So it looks like you have only 1 request object ("var req"); That can be the source of your problem. You'll need req1 and req2. Also, be sure you call the constructor every time you're going to send a new request. Good luck!
I changed the var req; to var req1; and still no changes in the functionality. -
<script type='text/javascript'>
-
var req;
-
-
function navigate(month,year) {
-
var url = "calendar.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type='text/javascript'>
-
var req1;
-
-
function navigate1(month,year) {
-
var url = "calendar1.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req1 = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req 1= new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req1.open("GET", url, true);
-
req1.onreadystatechange = callback;
-
req1.send(null);
-
}
-
-
function callback1() {
-
if(req1.readyState == 4) {
-
if(req1.status == 200) {
-
response = req1.responseText;
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req1.statusText);
-
}
-
}
-
}
-
</script>
-
<script type="text/javascript">
-
function init()
-
-
{
-
navigate("","");
-
navigate1("","");
-
}
-
//-->
-
</script>
-
</head>
-
<body onLoad="init()">
-
It isn't even opening a second instance of the calendar. That is also one of the problems
I changed the var req; to var req1; and still no changes in the functionality. -
<script type='text/javascript'>
-
var req;
-
-
function navigate(month,year) {
-
var url = "calendar.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type='text/javascript'>
-
var req1;
-
-
function navigate1(month,year) {
-
var url = "calendar1.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req1 = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req 1= new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req1.open("GET", url, true);
-
req1.onreadystatechange = callback;
-
req1.send(null);
-
}
-
-
function callback1() {
-
if(req1.readyState == 4) {
-
if(req1.status == 200) {
-
response = req1.responseText;
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req1.statusText);
-
}
-
}
-
}
-
</script>
-
<script type="text/javascript">
-
function init()
-
-
{
-
navigate("","");
-
navigate1("","");
-
}
-
//-->
-
</script>
-
</head>
-
<body onLoad="init()">
-
It isn't even opening a second instance of the calendar. That is also one of the problems
I always end up doing something like this to be sure my ajax is wired right: -
function callback1() {
-
if(req1.readyState == 4) {
-
alert("got a response");
-
if(req1.status == 200) {
-
response = req1.responseText;
-
alert ("response was: " + response.Text);
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req1.statusText);
-
}
-
}
-
}
-
See if you are getting those alert messages back properly. I don't have access to php right now or I'd fire it up and see what was going on first hand.
In your first post you had the following code (part of it)[php]function callback1() {
if(req.readyState == 4) {
if(req.status == 200) {
response = req.responseText;
document.getElementById("calendar1").innerHTML = response;
} else {
alert("There was a problem retrieving the data:\n" + req.statusText);
}
}
}
</script>
<script type="text/javascript">
function init()
{
navigate("","");
navigate1("","");
}
//-->
</script>
</head>
<body onLoad="init()">
<div id="calendar" style="margin-top: 20px;margin-bottom: 20px"></div>
</body>
</html>[/php]
In your JS statement you address document.getElementById("calendar1").
In your HTML you have defined the div as <div id="calendar" style="margin-top: 20px;margin-bottom: 20px"></div>\
Looks like the two id's are not identical.
Ronald :cool:
OK, here is what I have going.
b1randon, I put in the 'alert("response was: " + response.Text);' and am receiving the message that it is 'undefined'.
Ronald, I changed the div id to include both calendar and calendar1
Am I barking up the wrong tree trying to go this route? Or is there something blatant that I am missing?
The page is located at here
What is this doing?[html]I put in the 'alert("response was: " + response.Text);'[/html]. If the response data was sent back to JS as plain text, there is no response.Text, just response. So your alert should be[html]alert("response was: " + response);[/html]
Ronald :cool:
Ronald, I followed the example from b1randon in regards to the response.
I did get it figured out (at least the javascript/AJAX) part. There were two errors. In the function navigate1 it was calling callback() not callback1() and then I changed the body OnLoad from init() to navigate("","");navigate1("","") and dropped the function init() alltogether.
Thank you again. The little tips led me in the right direction. This is a great forum!
:)
Here is the correct code in the event that someone would like to use it in the future.
ajax_calendar.php -
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
-
<html>
-
<head>
-
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
-
<title>Your Title</title>
-
<link rel='stylesheet' type='text/css' href='calendar_style.css'>
-
<script type='text/javascript'>
-
var req;
-
-
function navigate(month,year) {
-
var url = "calendar.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type='text/javascript'>
-
var req1;
-
-
function navigate1(month,year) {
-
var url = "calendar1.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req1 = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req1 = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req1.open("GET", url, true);
-
req1.onreadystatechange = callback1;
-
req1.send(null);
-
}
-
-
function callback1() {
-
if(req1.readyState == 4) {
-
if(req1.status == 200) {
-
response = req1.responseText;
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req1.statusText);
-
}
-
}
-
}
-
</script>
-
</head>
-
<body onLoad='navigate("","");navigate1("","")'>
-
<div id='calendar' style='margin-top: 20px;margin-bottom: 20px'></div>
-
<div id='calendar1' style='margin-top: 100px;margin-bottom: 20px'></div>
-
</body>
-
</html>
-
calendar.php -
<?
-
-
$output = '';
-
-
if($_GET[month] == '' && $$_GET[year] == '') {
-
$time = time();
-
$month = date('n',$time);
-
$year = date('Y',$time);
-
}
-
-
$date = getdate(mktime(0,0,0,$month,1,$year));
-
$today = getdate();
-
$hours = $today[hours];
-
$mins = $today[minutes];
-
$secs = $today[seconds];
-
-
if(strlen($hours)<2) $hours="0".$hours;
-
if(strlen($mins)<2) $mins="0".$mins;
-
if(strlen($secs)<2) $secs="0".$secs;
-
-
$days=date("t",mktime(0,0,0,$month,1,$year));
-
$start = $date[wday]+1;
-
$name = $date[month];
-
$year2 = $date[year];
-
$offset = $days + $start - 1;
-
-
if($month==12) {
-
$next=1;
-
$nexty=$year + 1;
-
} else {
-
$next=$month + 1;
-
$nexty=$year;
-
}
-
-
if($month==1) {
-
$prev=12;
-
$prevy=$year - 1;
-
} else {
-
$prev=$month - 1;
-
$prevy=$year;
-
}
-
-
if($offset <= 28) $weeks=28;
-
elseif($offset > 35) $weeks = 42;
-
else $weeks = 35;
-
-
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
-
<tr>
-
<td colspan='7'>
-
<table border='0' width='100%'>
-
<tr>
-
<td valign='middle'>
-
<a href='javascript:navigate($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate($next,$nexty)'><img src='right.gif' border='0'></a>
-
</td>
-
<td align='right'>
-
<div id='heading'>$name $year2</div>
-
</td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td class='dayhead'>Sun</td>
-
<td class='dayhead'>Mon</td>
-
<td class='dayhead'>Tue</td>
-
<td class='dayhead'>Wed</td>
-
<td class='dayhead'>Thu</td>
-
<td class='dayhead'>Fri</td>
-
<td class='dayhead'>Sat</td>
-
</tr>";
-
-
$col=1;
-
$cur=1;
-
$next=0;
-
-
for($i=1;$i<=$weeks;$i++) {
-
if($next==3) $next=0;
-
if($col==1) $output.="<tr class='dayrow'>";
-
-
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
-
-
if($i <= ($days+($start-1)) && $i >= $start) {
-
$output.="<div";
-
-
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
-
$output.="><b>$cur</b>";
-
-
$output.="</div></td>";
-
$cur++;
-
$col++;
-
} else {
-
$output.=" </td>";
-
$col++;
-
}
-
-
if($col==8) {
-
$output.="</tr>";
-
$col=1;
-
}
-
}
-
-
$output.="</table>";
-
-
echo $output;
-
-
?>
-
calendar1.php -
<?
-
-
$output = '';
-
-
if($_GET[month] == '' && $$_GET[year] == '') {
-
$time = time();
-
$month = date('n',$time);
-
$year = date('Y',$time);
-
}
-
-
$date = getdate(mktime(0,0,0,$month,1,$year));
-
$today = getdate();
-
$hours = $today[hours];
-
$mins = $today[minutes];
-
$secs = $today[seconds];
-
-
if(strlen($hours)<2) $hours="0".$hours;
-
if(strlen($mins)<2) $mins="0".$mins;
-
if(strlen($secs)<2) $secs="0".$secs;
-
-
$days=date("t",mktime(0,0,0,$month,1,$year));
-
$start = $date[wday]+1;
-
$name = $date[month];
-
$year2 = $date[year];
-
$offset = $days + $start - 1;
-
-
if($month==12) {
-
$next=1;
-
$nexty=$year + 1;
-
} else {
-
$next=$month + 1;
-
$nexty=$year;
-
}
-
-
if($month==1) {
-
$prev=12;
-
$prevy=$year - 1;
-
} else {
-
$prev=$month - 1;
-
$prevy=$year;
-
}
-
-
if($offset <= 28) $weeks=28;
-
elseif($offset > 35) $weeks = 42;
-
else $weeks = 35;
-
-
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
-
<tr>
-
<td colspan='7'>
-
<table border='0' width='100%'>
-
<tr>
-
<td valign='middle'>
-
<a href='javascript:navigate1($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate1(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate1($next,$nexty)'><img src='right.gif' border='0'></a>
-
</td>
-
<td align='right'>
-
<div id='heading'>c1 $name $year2</div>
-
</td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td class='dayhead'>Sun</td>
-
<td class='dayhead'>Mon</td>
-
<td class='dayhead'>Tue</td>
-
<td class='dayhead'>Wed</td>
-
<td class='dayhead'>Thu</td>
-
<td class='dayhead'>Fri</td>
-
<td class='dayhead'>Sat</td>
-
</tr>";
-
-
$col=1;
-
$cur=1;
-
$next=0;
-
-
for($i=1;$i<=$weeks;$i++) {
-
if($next==3) $next=0;
-
if($col==1) $output.="<tr class='dayrow'>";
-
-
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
-
-
if($i <= ($days+($start-1)) && $i >= $start) {
-
$output.="<div";
-
-
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
-
$output.="><b>$cur</b>";
-
-
$output.="</div></td>";
-
$cur++;
-
$col++;
-
} else {
-
$output.=" </td>";
-
$col++;
-
}
-
-
if($col==8) {
-
$output.="</tr>";
-
$col=1;
-
}
-
}
-
-
$output.="</table>";
-
-
echo $output;
-
-
?>
-
Ronald, I followed the example from b1randon in regards to the response.
I did get it figured out (at least the javascript/AJAX) part. There were two errors. In the function navigate1 it was calling callback() not callback1() and then I changed the body OnLoad from init() to navigate("","");navigate1("","") and dropped the function init() alltogether.
Thank you again. The little tips led me in the right direction. This is a great forum!
:)
Here is the correct code in the event that someone would like to use it in the future.
ajax_calendar.php -
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
-
<html>
-
<head>
-
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
-
<title>Your Title</title>
-
<link rel='stylesheet' type='text/css' href='calendar_style.css'>
-
<script type='text/javascript'>
-
var req;
-
-
function navigate(month,year) {
-
var url = "calendar.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req.open("GET", url, true);
-
req.onreadystatechange = callback;
-
req.send(null);
-
}
-
-
function callback() {
-
if(req.readyState == 4) {
-
if(req.status == 200) {
-
response = req.responseText;
-
document.getElementById("calendar").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req.statusText);
-
}
-
}
-
}
-
</script>
-
<script type='text/javascript'>
-
var req1;
-
-
function navigate1(month,year) {
-
var url = "calendar1.php?month="+month+"&year="+year;
-
if(window.XMLHttpRequest) {
-
req1 = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
req1 = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
req1.open("GET", url, true);
-
req1.onreadystatechange = callback1;
-
req1.send(null);
-
}
-
-
function callback1() {
-
if(req1.readyState == 4) {
-
if(req1.status == 200) {
-
response = req1.responseText;
-
document.getElementById("calendar1").innerHTML = response;
-
} else {
-
alert("There was a problem retrieving the data:\n" + req1.statusText);
-
}
-
}
-
}
-
</script>
-
</head>
-
<body onLoad='navigate("","");navigate1("","")'>
-
<div id='calendar' style='margin-top: 20px;margin-bottom: 20px'></div>
-
<div id='calendar1' style='margin-top: 100px;margin-bottom: 20px'></div>
-
</body>
-
</html>
-
calendar.php -
<?
-
-
$output = '';
-
-
if($_GET[month] == '' && $$_GET[year] == '') {
-
$time = time();
-
$month = date('n',$time);
-
$year = date('Y',$time);
-
}
-
-
$date = getdate(mktime(0,0,0,$month,1,$year));
-
$today = getdate();
-
$hours = $today[hours];
-
$mins = $today[minutes];
-
$secs = $today[seconds];
-
-
if(strlen($hours)<2) $hours="0".$hours;
-
if(strlen($mins)<2) $mins="0".$mins;
-
if(strlen($secs)<2) $secs="0".$secs;
-
-
$days=date("t",mktime(0,0,0,$month,1,$year));
-
$start = $date[wday]+1;
-
$name = $date[month];
-
$year2 = $date[year];
-
$offset = $days + $start - 1;
-
-
if($month==12) {
-
$next=1;
-
$nexty=$year + 1;
-
} else {
-
$next=$month + 1;
-
$nexty=$year;
-
}
-
-
if($month==1) {
-
$prev=12;
-
$prevy=$year - 1;
-
} else {
-
$prev=$month - 1;
-
$prevy=$year;
-
}
-
-
if($offset <= 28) $weeks=28;
-
elseif($offset > 35) $weeks = 42;
-
else $weeks = 35;
-
-
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
-
<tr>
-
<td colspan='7'>
-
<table border='0' width='100%'>
-
<tr>
-
<td valign='middle'>
-
<a href='javascript:navigate($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate($next,$nexty)'><img src='right.gif' border='0'></a>
-
</td>
-
<td align='right'>
-
<div id='heading'>$name $year2</div>
-
</td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td class='dayhead'>Sun</td>
-
<td class='dayhead'>Mon</td>
-
<td class='dayhead'>Tue</td>
-
<td class='dayhead'>Wed</td>
-
<td class='dayhead'>Thu</td>
-
<td class='dayhead'>Fri</td>
-
<td class='dayhead'>Sat</td>
-
</tr>";
-
-
$col=1;
-
$cur=1;
-
$next=0;
-
-
for($i=1;$i<=$weeks;$i++) {
-
if($next==3) $next=0;
-
if($col==1) $output.="<tr class='dayrow'>";
-
-
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
-
-
if($i <= ($days+($start-1)) && $i >= $start) {
-
$output.="<div";
-
-
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
-
$output.="><b>$cur</b>";
-
-
$output.="</div></td>";
-
$cur++;
-
$col++;
-
} else {
-
$output.=" </td>";
-
$col++;
-
}
-
-
if($col==8) {
-
$output.="</tr>";
-
$col=1;
-
}
-
}
-
-
$output.="</table>";
-
-
echo $output;
-
-
?>
-
calendar1.php -
<?
-
-
$output = '';
-
-
if($_GET[month] == '' && $$_GET[year] == '') {
-
$time = time();
-
$month = date('n',$time);
-
$year = date('Y',$time);
-
}
-
-
$date = getdate(mktime(0,0,0,$month,1,$year));
-
$today = getdate();
-
$hours = $today[hours];
-
$mins = $today[minutes];
-
$secs = $today[seconds];
-
-
if(strlen($hours)<2) $hours="0".$hours;
-
if(strlen($mins)<2) $mins="0".$mins;
-
if(strlen($secs)<2) $secs="0".$secs;
-
-
$days=date("t",mktime(0,0,0,$month,1,$year));
-
$start = $date[wday]+1;
-
$name = $date[month];
-
$year2 = $date[year];
-
$offset = $days + $start - 1;
-
-
if($month==12) {
-
$next=1;
-
$nexty=$year + 1;
-
} else {
-
$next=$month + 1;
-
$nexty=$year;
-
}
-
-
if($month==1) {
-
$prev=12;
-
$prevy=$year - 1;
-
} else {
-
$prev=$month - 1;
-
$prevy=$year;
-
}
-
-
if($offset <= 28) $weeks=28;
-
elseif($offset > 35) $weeks = 42;
-
else $weeks = 35;
-
-
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
-
<tr>
-
<td colspan='7'>
-
<table border='0' width='100%'>
-
<tr>
-
<td valign='middle'>
-
<a href='javascript:navigate1($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate1(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate1($next,$nexty)'><img src='right.gif' border='0'></a>
-
</td>
-
<td align='right'>
-
<div id='heading'>c1 $name $year2</div>
-
</td>
-
</tr>
-
</table>
-
</td>
-
</tr>
-
<tr>
-
<td class='dayhead'>Sun</td>
-
<td class='dayhead'>Mon</td>
-
<td class='dayhead'>Tue</td>
-
<td class='dayhead'>Wed</td>
-
<td class='dayhead'>Thu</td>
-
<td class='dayhead'>Fri</td>
-
<td class='dayhead'>Sat</td>
-
</tr>";
-
-
$col=1;
-
$cur=1;
-
$next=0;
-
-
for($i=1;$i<=$weeks;$i++) {
-
if($next==3) $next=0;
-
if($col==1) $output.="<tr class='dayrow'>";
-
-
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
-
-
if($i <= ($days+($start-1)) && $i >= $start) {
-
$output.="<div";
-
-
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
-
$output.="><b>$cur</b>";
-
-
$output.="</div></td>";
-
$cur++;
-
$col++;
-
} else {
-
$output.=" </td>";
-
$col++;
-
}
-
-
if($col==8) {
-
$output.="</tr>";
-
$col=1;
-
}
-
}
-
-
$output.="</table>";
-
-
echo $output;
-
-
?>
-
Glad that I could be of service. Thanks for posting the solution. Congrats too, multiple XMLRequest objects can be tricky.
No Problem,
Now comes the fun part of querying the DB and setting up the output characteristics.
Hey, I have question. It seems that navigation in header is not working properly (month) . When I click for March 2007, from February 2007 it shows December 1999..Where is the problem? Thnx
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Seguros Catatumbo |
last post by:
Hi guys, i am having some weird issue with an ajax page.
I am designing a simple ajax calendar, because the one over yahoo is
about 200kb long, and mine is 9kb and really simple.
I am using...
|
by: www.web20developers.com |
last post by:
http://www.web20developers.com
http://www.web20developers.com/index.php?option=com_content&task=view...
Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell
AJAX -...
|
by: jobs |
last post by:
I've got a masterpage with a custom control that has a calendar. when
dates on the calendar are selected, it sets a session variable. that
calender is on every page via the master page. In the home...
|
by: =?Utf-8?B?UGFycm90?= |
last post by:
I applied the following Ajax code in my web page which has a calendar control
to keep my page from completely reloading everytime something was changed.
<atlas:ScriptManager ID="ScriptManager1"...
|
by: JohnnieTech |
last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1...
|
by: =?Utf-8?B?Q2VzYXI=?= |
last post by:
I have the ASP.NET 2.0 AJAX Extensions 1.0 installed (v1.0.61025). As to the
web.config file, I'm using the one created using the ASP.NET AJAX-Enabled
website ...
This error is due to that I'm...
|
by: ton |
last post by:
Hi,
I wander what to do. I'm developing a webapplication. One of the parts is to
show records from a database.
To modifiy a value, text of relational link or date I would like to use Ajax
where...
|
by: Mark B |
last post by:
This is my first try at using AJAX. I want the calendars to be enabled if
the user checks CheckBox1. It works OK for a normal all page refresh but
once I introduced the AJAX code it stopped...
|
by: bellgodz |
last post by:
Hello,
I have a text box on an .aspx page that an AJAX calendar extender is tied to. When this page is loaded the text box in question is populated with a date from a selected record. I've tried...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |