?
Solved

Php pop-up calendar

Posted on 2005-03-31
3
Medium Priority
?
398 Views
Last Modified: 2013-11-28
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
Comment
Question by:Dcom4CIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:munkywrench
ID: 13670065
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
 
LVL 1

Expert Comment

by:a2liter
ID: 13673510
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
 
LVL 3

Accepted Solution

by:
lokip earned 2000 total points
ID: 13677402
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn about the eCommerce marketing trends for the year ahead.
Read this article and get to know some best tips for outsourcing client PPC work to a white label PPC agency.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question