-
- 428 Posts
Hello,
You can use a jQuery date picker, like this one:
http://docs.jquery.com/UI/Datepicker
There are others plugins, but this one is easy to implement and very flexible.
Intégrateur web freelance
-
- 24,544 Posts
This datepicker is very lightweight and I implemented it for the front end in about 20 minutes:
http://www.frequency-decoder.com/2006/10/02/unobtrusive-date-picker-widgit-update
-
- 28 Posts
BobRay,
I downloaded the datepicker.js file you did and uploaded it to my test site. Are you saying that it requires no CSS files to be referenced in the header because the example I saw referenced two CSS files?
What would be the code for the most simple call I can use in modx cms for a simple form field if this is the case? Hate to ask, can you provide some sample code? All I want is a simple field and calendar that starts with today’s date.
Thanks a bunch!
Joel Logan
-
- 24,544 Posts
Quote from: joellogan at Nov 17, 2010, 03:11 AM
BobRay,
I downloaded the datepicker.js file you did and uploaded it to my test site. Are you saying that it requires no CSS files to be referenced in the header because the example I saw referenced two CSS files?
What would be the code for the most simple call I can use in modx cms for a simple form field if this is the case? Hate to ask, can you provide some sample code? All I want is a simple field and calendar that starts with today’s date.
Thanks a bunch!
Joel Logan
You need a snippet to load the js and css. Something like this (you’ll need to correct the paths to the js and css files):
<?php
/* DatePicker snippet */
$modx->regClientCSS(MODX_ASSETS_URL . 'components/newspublisher/css/datepicker.css');
$modx->regClientStartupScript(MODX_ASSETS_URL . 'components/newspublisher/js/datepicker.js');
$output = '<p><label for="unpub_date">Unpublished Date: </label><input type="text" class="w4em format-d-m-y divider-dash no-transparency"
id="unpub_date" name="unpub_date" maxlength="10" size="9" readonly="readonly" value="[[+unpub_date]]" /></p>';
return $output;
There’s a way to make it start at today’s date. Check at the link in the post above (or Google "unobtrusive datepicker" for more recent docs).
-
- 24,544 Posts
Quote from: joellogan at Nov 19, 2010, 01:10 AM
BobRay,
I have tried everything you were saying to do and it doesn’t show the calendar. I created the directories and uploaded the files to match your URLs on the css and js files. Can you tell anything from the below?
http://www.usmcgraduations.com/testofmodx/index.php?id=70
Thanks so much,
Joel Logan
Try putting
<div class="datepicker"> ... </div>
around the date input.