Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

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>&nbsp;</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>&nbsp;</td>"; }
      echo "</tr>";
      }
 }
?>
</table>


0
Dcom4CIT
Asked:
Dcom4CIT
1 Solution
 
munkywrenchCommented:
I don't understand what you mean but you could always do it with DHTML and javascript.

e.g

<script language="javascript">

    function calendarshow() {
 
       calendarObj = document.getElementById('calendar');

       if (calendarObj.style.display == "none") {

           calendarObj.style.display = "";

        } else {

            calendarObj.style.display = "none";

        }

    }


</script>

<a href="#" onClick="calendarshow()">Show Calendar</a>


<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. : )
0
 
a2literCommented:
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.
0
 
lokipCommented:
Check: http://www.dynarch.com/projects/calendar/ for a rocking pop up calendar. IIRC, Mishoo (the designer) has sufficient examples to get it running quickly. I believe the package contains a PHP class for easily generating them on the fly, too.

Regards,
eric
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now