Is there a good PHP Calendar Popup, that can be adjusted?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Is there a good PHP Calendar Popup, that can be adjusted?

Post by simonmlewis »

I am building a little tool where the administrator can click a calendar button, up pops a calendar, they select the current date, ad it processes to show the attendance of a person to an event.

However, I want them to be able to backdate it, so they can choose a few days ago. So it cannot just use the current date.

It would also help if I could use PHP to click a popup, and be able to highlight the date in the database too. For example, if they date needs to be changed.

Is there such a thing? I know PHP probably won't have the relevant script as its Server Side, but anything that can do it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Celauran »

Could be something as simple as jQuery UI datepicker attached to a change listener. Alternately, the button could open a modal (or a new tab) which would display a calendar based on the month and year passed in as parameters. Definitely sounding like a combination of JavaScript and PHP, the former sending AJAX calls to the latter.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Problem is, Ive never worked out how to do "change listener" scripts.
I did try, via a thread on here. It was about adding to a PHP basket, and showing the update in the template. But it never worked and I gave up.

A simple date picker is sufficient, so they select that, and hit Go.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

It's working, to a point. It seems to be submitting it in the American format, rather than the SQL format:

08/04/2015 for 4th Aug, rather than: 2015-08-04.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Celauran »

simonmlewis wrote:Problem is, Ive never worked out how to do "change listener" scripts.
You absolutely must learn this. JavaScript usage is ever increasing and that's not going to change any time soon.

https://learn.jquery.com/events/event-basics/
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Celauran »

simonmlewis wrote:It's working, to a point. It seems to be submitting it in the American format, rather than the SQL format:

08/04/2015 for 4th Aug, rather than: 2015-08-04.
What's working? What does the code look like? That should be fairly trivial to change.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Christopher »

simonmlewis wrote:It's working, to a point. It seems to be submitting it in the American format, rather than the SQL format:

08/04/2015 for 4th Aug, rather than: 2015-08-04.
Check the docs or source. There should be a way to set the format of the date. I usually switch it to database style yyyy-mm-dd.
(#10850)
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Code: Select all

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
   <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script> 
  $dateattend = isset($_POST['dateattend']) ? $_POST['dateattend'] : null;

<form method='POST' action='/index.php?page=search&search=$search&memberid=$row->memberid&u=dateattend'>
<input type='text' id='datepicker' name='dateattend'>
<input type='submit' value='Go'>
</form>
I don't see anything that means i can alter it's format.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Oh that's cool, didn't spot that.
Is it possible to change it from being an input field, to being an actiual image or fontawesome icon?
I guess it would have to hide the field, but not sure the best way to achieve it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Can the date be pre-set per page?
This is for date of birthday, so be good if I can set it at a middle ground, like 1st January 1985.... that sort of thing.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Celauran »

Do you mean with a default value?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Yes I do. Is this possible in the top bit of code?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by simonmlewis »

Can the datepicker also be enabled to push forward year by year? Because entering DOB and set at 1985, would be a pain if the person was born in 1991.... Sooooo many clicks...!!!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Is there a good PHP Calendar Popup, that can be adjusted

Post by Celauran »

simonmlewis wrote:Yes I do. Is this possible in the top bit of code?
Yes, using value="whatever" as you would in any other input element.
Post Reply