Datepicker - second starts with date of first (openLastView)

terrywest 23 Jul, 2012
Currently I have two date pickers in my form and working.

I would like to get the second date picker to start with the date chosen in the first datepicker.

So far I have managed to find 'openLastView' in the MooTools Datepicker Librarybut i'm unable to get it to work.

So far I have (datepicker2 = second datepicker class)

datepicker2::{openLastView: 'true'}


What's the correct santax get this working?
GreyHead 25 Jul, 2012
Hi TerryWest,

I had a little explore of the RangePicker version of the MooTools datepicker and wondered if this does what you need? See the image below and a test form here
The test form is created using a text input with the id date_range and this code in a Load JS action in the On Load event:
<?php
JHTML::_('behavior.mootools');
$picker_array = array(
  'Picker.js',
  'Picker.Attach.js',
  'Picker.Date.js',
  'Picker.Date.Range.js',
  'Locale.en-GB.DatePicker.js'
);
$doc =& JFactory::getDocument();
foreach ( $picker_array as $v ) {
  $doc->addScript(JURI::base().'components/com_chronoforms/js/datepicker_moo/'.$v);
}
$doc->addStyleSheet(JURI::base().'components/com_chronoforms/js/datepicker_moo/datepicker.css');
$doc->addStyleDeclaration("
.datepicker tr, .datepicker td {
  border:none;
}
");
?>
var dp, date_range;
window.addEvent('domready', function() {
  date_range = $('date_range');
  dp = new Picker.Date.Range(date_range, {
    pickerClass: 'datepicker',
    columns: 2,
    minDate: new Date()
  });
});
Note: Joomla! isn't too good at handling the order in which scripts get loaded in the header so the first half of this code is about fixing that :-(

Bob

PS You can change the column setting up to a maximum of 5 if needed. This will select a few weeks or a several years.

Unfortunately the CSS that comes with the DatePicker only supports the Range Picker in the default style-sheet. The other styles would need to be extended to add the extra columns and the footer :-(
terrywest 30 Jul, 2012
Hi Bob,

I'm afraid this is not really what I'm looking for, I did consider this option.

Ideally I'm looking for two separate fields and date-pickers, I just want to update what I already have without it impacting on other things.

Is it possible to do this ?
This topic is locked and no more replies can be posted.