PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jul 23, 2017 9:53 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed May 17, 2017 5:47 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
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.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 5:50 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
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.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 6:36 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
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.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 6:37 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
oh date picker looks good.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 7:01 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
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.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 7:36 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
datepicker? Yeah, it should be one of the options.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 7:39 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
http://api.jqueryui.com/datepicker/#option-dateFormat
Got it.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 8:02 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
<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.


Top
 Profile  
 
PostPosted: Wed May 17, 2017 8:32 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
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.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 5:06 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
This is what I have at the moment:

Syntax: [ Download ] [ Hide ]
<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:
Syntax: [ Download ] [ Hide ]
<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.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 5:30 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6254
Location: Montreal, Canada
Syntax: [ Download ] [ Hide ]
$( ".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.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Thu May 18, 2017 6:22 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
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.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 9:07 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
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.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 10:38 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4231
Location: United Kingdom
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.


Top
 Profile  
 
PostPosted: Thu May 18, 2017 10:53 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6457
Location: WA, USA
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot], Majestic-12 [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group