Dcom4CIT
asked on
Php pop-up calendar
Hi,
I have code for a php calendar for a website i'm working on but ned to make it a popup calendar. How would i do this? This is the code i found for the calendar......
<?
if (isset($_GET['monthno'])) $monthno = $_GET['monthno'];
if (isset($_GET['year'])) $year = $_GET['year'];
if (!isset($monthno)) {
$monthno=date(n);
}
if (!isset($year)) {
$year = date(Y);
}
$monthfulltext = date(F, mktime(0, 0, 0, $monthno, 1, $year));
$monthshorttext = date(M, mktime(0, 0, 0, $monthno, 1, $year));
$day_in_mth = date(t, mktime(0, 0, 0, $monthno, 1, $year)) ;
$day_text = date(D, mktime(0, 0, 0, $monthno, 1, $year));
?>
<style type="text/css">
.tdday { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #0000ff;
font-weight: normal;
font-size: 9px;
width: 26px;
line-height: 20px;
color: #ffffff;
vertical-align: middle;
text-align: center;
}
.tdtoday { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: lightgreen;
font-weight: bold;
font-size: 10px;
line-height: 16px;
width: 26px;
color: #000000;
vertical-align: middle;
text-align: center;
}
.tdheading { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #a0a0a0;
font-weight: bold;
font-size: 10px;
line-height: 20px;
color: #ffffff;
vertical-align: middle;
text-align: center;
}
.tddate { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #f0f0f0;
font-weight: normal;
font-size: 10px;
line-height: 16px;
width: 26px;
color: #000000;
vertical-align: middle;
text-align: center;
}
.caltable { border: #a0a0a0;
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
margin-bottom: 0px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px
}
</style>
<table class=caltable bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="1" width=97%>
<tr><td colspan=7 class=tdheading><? echo $monthfulltext." ".$year ?></td></tr>
<tr>
<td class=tdday>Sun</td><td class=tdday>Mon</td><td class=tdday>Tue</td><td class=tdday>Wed</td><td class=tdday>Thu</td><td class=tdday>Fri</td>
<td class=tdday>Sat</td>
</tr>
<tr>
<?
$day_of_wk = date(w, mktime(0, 0, 0, $monthno, 1, $year));
if ($day_of_wk <> 0){
for ($i=0; $i<$day_of_wk; $i++)
{ echo "<td class=tddate> </td>"; }
}
for ($date_of_mth = 1; $date_of_mth <= $day_in_mth; $date_of_mth++) {
if ($day_of_wk = 0){
for ($i=0; $i<$day_of_wk; $i++);
{ echo "<tr>"; }
}
$day_text = date(D, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
$date_no = date(j, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
$day_of_wk = date(w, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
if ( $date_no == date(j) && $monthno == date(n) )
{ echo "<td class=tdtoday>".$date_no." </td>"; }
else{
echo "<td class=tddate>".$date_no."< /td>"; }
If ( $day_of_wk == 6 ) { echo "</tr>"; }
If ( $day_of_wk < 6 && $date_of_mth == $day_in_mth ) {
for ( $i = $day_of_wk ; $i < 6; $i++ ) {
echo "<td class=tddate> </td>"; }
echo "</tr>";
}
}
?>
</table>
I have code for a php calendar for a website i'm working on but ned to make it a popup calendar. How would i do this? This is the code i found for the calendar......
<?
if (isset($_GET['monthno'])) $monthno = $_GET['monthno'];
if (isset($_GET['year'])) $year = $_GET['year'];
if (!isset($monthno)) {
$monthno=date(n);
}
if (!isset($year)) {
$year = date(Y);
}
$monthfulltext = date(F, mktime(0, 0, 0, $monthno, 1, $year));
$monthshorttext = date(M, mktime(0, 0, 0, $monthno, 1, $year));
$day_in_mth = date(t, mktime(0, 0, 0, $monthno, 1, $year)) ;
$day_text = date(D, mktime(0, 0, 0, $monthno, 1, $year));
?>
<style type="text/css">
.tdday { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #0000ff;
font-weight: normal;
font-size: 9px;
width: 26px;
line-height: 20px;
color: #ffffff;
vertical-align: middle;
text-align: center;
}
.tdtoday { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: lightgreen;
font-weight: bold;
font-size: 10px;
line-height: 16px;
width: 26px;
color: #000000;
vertical-align: middle;
text-align: center;
}
.tdheading { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #a0a0a0;
font-weight: bold;
font-size: 10px;
line-height: 20px;
color: #ffffff;
vertical-align: middle;
text-align: center;
}
.tddate { font-family: Verdana, Arial, Helvetica, sans-serif;
background-color: #f0f0f0;
font-weight: normal;
font-size: 10px;
line-height: 16px;
width: 26px;
color: #000000;
vertical-align: middle;
text-align: center;
}
.caltable { border: #a0a0a0;
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
margin-bottom: 0px;
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px
}
</style>
<table class=caltable bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="1" width=97%>
<tr><td colspan=7 class=tdheading><? echo $monthfulltext." ".$year ?></td></tr>
<tr>
<td class=tdday>Sun</td><td class=tdday>Mon</td><td class=tdday>Tue</td><td class=tdday>Wed</td><td class=tdday>Thu</td><td class=tdday>Fri</td>
<td class=tdday>Sat</td>
</tr>
<tr>
<?
$day_of_wk = date(w, mktime(0, 0, 0, $monthno, 1, $year));
if ($day_of_wk <> 0){
for ($i=0; $i<$day_of_wk; $i++)
{ echo "<td class=tddate> </td>";
}
for ($date_of_mth = 1; $date_of_mth <= $day_in_mth; $date_of_mth++) {
if ($day_of_wk = 0){
for ($i=0; $i<$day_of_wk; $i++);
{ echo "<tr>"; }
}
$day_text = date(D, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
$date_no = date(j, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
$day_of_wk = date(w, mktime(0, 0, 0, $monthno, $date_of_mth, $year));
if ( $date_no == date(j) && $monthno == date(n) )
{ echo "<td class=tdtoday>".$date_no."
else{
echo "<td class=tddate>".$date_no."<
If ( $day_of_wk == 6 ) { echo "</tr>"; }
If ( $day_of_wk < 6 && $date_of_mth == $day_in_mth ) {
for ( $i = $day_of_wk ; $i < 6; $i++ ) {
echo "<td class=tddate> </td>";
echo "</tr>";
}
}
?>
</table>
Why not just use one that is already working, there are many verisons of pop up calendars out there. Here is one that I have used in the past and works just fine
http://www.mojavelinux.com/projects/popupcalendar/
Just do a search on google for popup calendar and there are many results returned.
Hope this helps.
http://www.mojavelinux.com/projects/popupcalendar/
Just do a search on google for popup calendar and there are many results returned.
Hope this helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
e.g
<script language="javascript">
function calendarshow() {
calendarObj = document.getElementById('c
if (calendarObj.style.display
calendarObj.style.display = "";
} else {
calendarObj.style.display = "none";
}
}
</script>
<a href="#" onClick="calendarshow()">S
<div id="calendar" style="display:none">
...calendar code goes here...
</div>
That will work for a calendar that appears, a calendar that slides into focus is more complicated. I might have got the CSS attributes wrong too. : )