Page 1 of 2
Is there a good PHP Calendar Popup, that can be adjusted?
Posted: Mon Aug 03, 2015 10:29 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 10:39 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 10:42 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 11:01 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 11:12 am
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/
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 11:13 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 11:31 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 12:18 pm
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 12:30 pm
by Celauran
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Mon Aug 03, 2015 12:44 pm
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Wed Sep 23, 2015 7:41 am
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.
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Wed Sep 23, 2015 8:09 am
by Celauran
Do you mean with a default value?
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Wed Sep 23, 2015 8:30 am
by simonmlewis
Yes I do. Is this possible in the top bit of code?
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Wed Sep 23, 2015 8:31 am
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...!!!
Re: Is there a good PHP Calendar Popup, that can be adjusted
Posted: Wed Sep 23, 2015 8:45 am
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.