Question

php popup Date Picker (NO JAVA - JUST PHP ONLY)

Asked by: Pern

id like to incorp a popup date picker into a site i have and id like it writen in php i have found java ones here are a few examples

http://www.calendarxp.net/tt_pop.shtml

and

http://www.javascriptkit.com/script/script2/timestamp.shtml

if i have a choice id like to have it slide out.

id like it in the format of YYYY-MM-DD for the forms input box

id like it in colors and to have a year/month/day picker just like the samples in java

im pretty flexible on this

and thanks in advane for any help
i wouldnt know the first place to start looking or evan how to code such a thing

Johnny
aka Pern

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2003-12-30 at 15:28:07ID20837618
Tags

php

,

date

,

picker

,

popup

Topic

PHP and Databases

Participating Experts
2
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Using php and popup dialogs
    i noticed on some websites they use popups to allow changes to a page. so you are at a page lets say and then you have a link to a popup which takes input then once you hit apply it will make changes to the original page! i just need to know how they pass that information? ...
  2. PHP and shtml
    Dear all, I'm currently coding a website. The website requires the use of templates (using shtml). However, I'm having great difficulting incorporating php into the actual templates. The main problem i'm having is the the php code doesn't pickup the $_GET values. For examp...
  3. PHP and popup box
    Hello, Is there a way to resize a window with PHP that was opened using PHP. I need a small popup window that does not get blocked by popup blockers. Bob
  4. PHP passing values to popup
    Hi, I'm using a PHP Event Calendar at http://www.softcomplex.com/products/php_event_calendar/ and was hoping someone could answer this question. Is it possible to pass a php variable from the main window to a popup window.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: lozlozPosted on 2003-12-30 at 16:47:33ID: 10019302

hi,

php is a server side language, whereas javascript is a client side language. what this means is that javascript can be used to modify the page displayed to the user based on user interaction without having to reload the page, whereas php can display dynamic data from databases but only to response to user input by reloading the page. this makes it impossible to do what you want without javascript. can i ask why you don't want to use javascript? you might find that it will work for you after all. you can combine the two technologies to produce a calendar based upon data from databases or any other data sources

cheers,

loz

 

by: lozlozPosted on 2003-12-30 at 16:51:06ID: 10019314

sorry, typo:

but only to response to user input by reloading the page

should read:

but only respond to user input by reloading the page

cheers,

loz

 

by: PernPosted on 2003-12-30 at 19:19:11ID: 10019808

lozloz;

Thanks for the reply and the nifty explination

i belive ive seen a php one someplace but for the life of me i cant remeber where.

in reply to your message:

What about a clicked icon like the java does to fire it.

if you look at thoses examples it has an icon on the page(query box)

{i dont have a problem with java so to speak i would just rather have the calender in php as i can understand php and i dont like java much and i try to not use it.}

the action would be to press an icon next to the input field to have the php calander popup.

i may use the java ones i gave examples for..as said id rather use php.
the form is html based and yes i can incorp the java into it.

any other answers???

thanks again!
Johnny
aka Pern

 

by: lozlozPosted on 2003-12-30 at 19:39:36ID: 10019871

hi,

i developed an events calendar once adapting some code for a basic calendar to include events. you could possibly incorporate it by having the icon which loads a popup window with this calendar class on it, fetching the current month from the query string.

the class is here: http://www.cascade.org.uk/software/php/calendar/index.php

so on your main page:

<a onClick="return open_popup("calendar_picker.php?m=<? print date("m"); ?>", 400, 200)" href="calendar_picker.php?m=<? print date("m"); ?>">

then you'd have calendar_picker.php having code to display the current month. you'd need to adapt it a bit to basically make each day a link which would have the href as: javascript:window.opener.document.form.field.value='<? print date("m", $timestamp"); ?>'

basically there you'd need to change form to the name of your form on the main page and field to that of the input field which will contain your date. also you'd have to change $timestamp to that of the timestamp for that month, or change the function to simply output the month if the class allows you to do that

hope that helps in some sort of way, it's quite hard to explain. have a look at that php calendar anyway

cheers,

loz

 

by: PernPosted on 2003-12-31 at 08:20:08ID: 10021989

lozloz;

Thanks again for the reply.

I decided to go with the java calxp one ( http://www.calendarxp.net/tt_pop.shtml )
i emailed the author and he said i could use it foir what i am doing.

I figured your right and i should not try to reinvent the wheel so to speak.

Ive never had an answer before so im not sure how to award the points.
I also have a question about it and am asking your advice on it.
Altho i used your orginal reply and went with java(as the why not use java parts)
was wondering how i shopuld award the points.
i pay for my membership so i dont really care abou the points
 (as i said only time so far ive had to use um)

awaiting your reply
Johnny
aka Pern
ps: my votes i give you the points (thanks againf for your time)

 

by: lozlozPosted on 2003-12-31 at 09:28:52ID: 10022393

to award points you simply accept an answer by clicking on the accept button next to a comment on the question. if you need to split the points between multiple answers in the future, there's an option at the bottom of the page to do this, but that's not relevant here seeing as i'm the only one who has commented. you choose a grade to match the standard of the replies as well

as for the question, i think using those premade jscript calendars are best seeing as there's no need to complicate it by adding php. if you want me to modify the javascript to change it to your format of data/time or colours then leave another message and i'll try and help out

cheers,

loz

 

by: RoonaanPosted on 2004-08-26 at 10:32:35ID: 11905275

Re:
I use the code below on my website.

It support multiple date selection fields. Whenever you want to have a date-selection field, you use the line below to add one, changing 'Fieldname' with any name you like/require.
<script type="text/javascript">addCal('Fieldname');</script>

In order for the above code to work, you have to add the javascript functions below into your <head> section:

<script>
  var ffield;
  function addCal(field)
  {
    document.write('<a href="calendar.php" target="_blank" style="margin:2px;" onClick="return showCal(' + field + ');"><img height="16" width="16" src="i/calendar.gif" border="0"></a>');
  }
  function showCal(field)
  {
    ffield = field;
    window.open('calendar.php', 'popcalendar','height=200,width=200,scrollbars=no,resizable=no,menubar=no,toolbar=no,location=no');
    return false;
  }
  function calendarPopupClick(value)
  {
    status = value;
    if(ffield) ffield.value = value;
  }
</script>

The addCal method ads a text-input field with a clickable image right next to it. When the image is clicked, the name of the textfield is stored in a javascript variable, just before a popup window is opened showing the php-calendar.
The calendar registers every dateselection and passes it to its window.opener window by calling window.opener.calendarPopupClick("click date value");
Because the name of the appropriate fieldname was stored into the javascript variable, javascript is able to set the textfields value with the value passed by the popup.

The Calendar.php code I use is shown below:
(some th-elements contain dutch abbreviations for the weekdays, I suppose you will manage to change that by yourself quite easily)

calendar.php
<?
//Check for date selectie from query string
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');
}
//check the current date
$now = mktime(0, 0, 0, $monthno, 1, $year);
$monthfulltext = date('F', $now);
$monthshorttext = date('M', $now);

//number of days
$day_in_mth = date('t', $now) ;
$day_text = date('D', $now);

//Find the selected year and date
$monthno = date('m', $now);
$year = date('Y', $now);
?>
<html>
  <head>
<style type="text/css">

.tdday { font-family: Verdana, Arial, Helvetica, sans-serif;
                  background-color: #8BBDDE;
                  font-weight: normal;
                  font-size: 9px;
                  width: 26px;
                  line-height: 20px;
                  color: #fff;
                  vertical-align: middle;
                  text-align: center;
}
.tdtoday { font-family: Verdana, Arial, Helvetica, sans-serif;
                  background-color: #DEECF7;
                  font-weight: bold;
                  font-size: 10px;
                  line-height: 16px;
                  width: 26px;
                  color: #000000;
                  vertical-align: middle;
                  text-align: center;
                  border:solid 1px #87BBDD;
}

.tdheading { font-family: Verdana, Arial, Helvetica, sans-serif;
                  background-color: #DEECF7;
                  font-weight: bold;
                  font-size: 10px;
                  line-height: 18px;
                  color: #000;
                  vertical-align: middle;
                  text-align: center;
                  background-image:url('../i/secth.png');
                  padding:0px;
}
.tddate { font-family: Verdana, Arial, Helvetica, sans-serif;
                  background-color: #E7F2F9;
                  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
}
#mnoprev, #mnonext {font-size:10px; font-family: Verdana, Arial, Helvetica, sans-serif; color:#999;}
#mnoprev {position:absolute;left:5px;bottom:5px;}
#mnonext {position:absolute;right:5px;bottom:5px;}
</style>
<title>Calendar</title>
</head>
<body>
<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">Zon</td><td class="tdday">Maa</td><td class="tdday">Din</td><td class="tdday">Woe</td><td class="tdday">Don</td><td class="tdday">Vri</td><td class="tdday">Zat</td>
</tr>
<tr>
<?
//When the first day in the month is not the first day of the week, add some empty cells
$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>'; }
}

//Show all days within the month
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));
   $neatdate = sprintf('%04d-%02d-%02d', intval($year), intval($monthno), intval($date_of_mth));
   if ( $date_no ==  date(j) &&  $monthno == date(n) )
     {  echo "<td class=tdtoday>".linkify($date_no, $neatdate)."</td>"; }
   else{
   echo "<td class=tddate>".linkify($date_no, $neatdate)."</td>";  }
   
   
   If ( $day_of_wk == 6 ) {  echo "</tr>"; }

//If last day of the month is not last day of the week, add empty cells.
   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>
<?php
  //display links to next and previous month;
  echo '<a id="mnoprev" href="?monthno='.($monthno-1).'&year='.$year.'">&lt;&lt;</a>';
  echo '<a id="mnonext" href="?monthno='.($monthno+1).'&year='.$year.'">&gt;&gt;</a>';

  /*
   function linkify generates a clickable day-of-month hyperlink, in order to pass
   any clicks to the parent window.
   */
  function linkify($text, $date)
  {
    return '<a style="cursor:pointer;" onClick="window.opener.calendarPopupClick(\''.$date.'\');">'.$text.'</a>';
  }
?>  
</body>
</html>

I hope this is somewhat helpfull in any way, as this is my first comment to Experts-Exchange and I might have not seen all the policies available, needed to be read before posting.

 

by: RoonaanPosted on 2004-08-26 at 10:36:24ID: 11905316

As I am unable to edit the above, I would like to add a 'working' example of the above calendar.php:

http://www.trickline.nl/events/tls/calendar.php

As the fields using this calendar are hidden within the administrators panel of my website I cannot show you a working example.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...