Page 1 of 2

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

Posted: Wed May 17, 2017 5:47 am
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?

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

Posted: Wed May 17, 2017 5:50 am
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

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

Posted: Wed May 17, 2017 6:36 am
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.

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

Posted: Wed May 17, 2017 6:37 am
by simonmlewis
oh date picker looks good.

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

Posted: Wed May 17, 2017 7:01 am
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...?

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

Posted: Wed May 17, 2017 7:36 am
by requinix
datepicker? Yeah, it should be one of the options.

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

Posted: Wed May 17, 2017 7:39 am
by simonmlewis

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

Posted: Wed May 17, 2017 8:02 am
by simonmlewis
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
$( ".selector" ).datepicker({
dateFormat: "dd-mm-yy"
});
</script>

Is this not correct?

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

Posted: Wed May 17, 2017 8:32 am
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.

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

Posted: Thu May 18, 2017 5:06 am
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.

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

Posted: Thu May 18, 2017 5:30 am
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.

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

Posted: Thu May 18, 2017 6:22 am
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'>

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

Posted: Thu May 18, 2017 9:07 am
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.

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

Posted: Thu May 18, 2017 10:38 am
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.

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

Posted: Thu May 18, 2017 10:53 am
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.