Is there a good Calendar script, that can post via PHP?

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 Calendar script, that can post via PHP?

Post by simonmlewis »

I am looking at adding a simple calendar to a webpage, so people can select the date, and then select a time, and submit so the information is passed over thru a PHP variable to a form.

It's so people can submit a preliminary booking date and time.

I know there isn't a PHP Calendar, as PHP is server side rather than that - but is there a nice neat calendar that is commonly used, that can be wide or small (and responsive), so that when it's select and 'submitted', it passes over that date?
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 Calendar script, that can post via PHP?

Post by simonmlewis »

This might work, but not sure how to put their date (that appears in the Span) into a variable for submission:
https://yuilibrary.com/yui/docs/calenda ... imple.html
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is there a good Calendar script, that can post via PHP?

Post by requinix »

datepicker is fairly popular.

For that YUI thing it looks like you're supposed to listen for the selectionChange event and update some hidden form element with the date.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good Calendar script, that can post via PHP?

Post by simonmlewis »

oh date picker looks good.
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 Calendar script, that can post via PHP?

Post by simonmlewis »

Is there a way I can alter the format of it, so it's dd/mm/yyyy, as that's how we do it in the UK...?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is there a good Calendar script, that can post via PHP?

Post by requinix »

datepicker? Yeah, it should be one of the options.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good Calendar script, that can post via PHP?

Post by simonmlewis »

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 Calendar script, that can post via PHP?

Post by simonmlewis »

<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
$( ".selector" ).datepicker({
dateFormat: "dd-mm-yy"
});
</script>

Is this not correct?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is there a good Calendar script, that can post via PHP?

Post by requinix »

Does it do what you want? I'm guessing not.

You do have jQuery and UI in the first place, right? Are you familiar with how jQuery works? Because just copying stuff from the documentation isn't going to work.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good Calendar script, that can post via PHP?

Post by simonmlewis »

This is what I have at the moment:

Code: Select all

<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  $( ".selector" ).datepicker({
  dateFormat: "dd-mm-yy"
});

$(document).on('change', '.div-toggle', function() {
  var target = $(this).data('target');
  var show = $("option:selected", this).data('show');
  $(target).children().addClass('hide');
  $(show).removeClass('hide');
});
$(document).ready(function(){
    $('.div-toggle').trigger('change');
});

  </script>
And this is the part of the form:

Code: Select all

<div class='book-left'>Preferred Date:</div>
<div class='book-right'><input type="text" name='date' id="datepicker" placeholder='Click to choose date'></div>	
<div style='clear: both'></div>
And no, the date still comes up month first.
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 Calendar script, that can post via PHP?

Post by Celauran »

Code: Select all

$( ".selector" ).datepicker({
  dateFormat: "dd-mm-yy"
});
What's going on here? I see no element with a class of "selector". You want that on the element the datepicker is actually attached to.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good Calendar script, that can post via PHP?

Post by simonmlewis »

But it's called datepicker?
<input type="text" name='date' id="datepicker" placeholder='Click to choose date'>.

Do you mean like this?
<input type="text" name='date' class='selector' id="datepicker" placeholder='Click to choose date'>
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is there a good Calendar script, that can post via PHP?

Post by requinix »

So
requinix wrote:Are you familiar with how jQuery works?
no.

Are you familiar with any UI libraries? I know you found a date thing for YUI, however that project is dead so it isn't the best thing to choose.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Is there a good Calendar script, that can post via PHP?

Post by simonmlewis »

So is that one a bit of a bad one to use then? I just want to have the date field correct.
I'm not familiar with UI libraries.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is there a good Calendar script, that can post via PHP?

Post by requinix »

It's fine to use, but if you don't know jQuery then you'll have to learn it.

(sigh)

What's your HTML for the form? Specifically, the inputs where the date and time are supposed to go.
Post Reply