Set start date on event

whitemage 24 Nov, 2015
How do I change the start date of a date field when an event is triggered?

At the moment I am trying to change the starting date of a field when the visitor sets another field but it is not working. The data attribute is being changed but it has no effect on the datepicker.
whitemage 25 Nov, 2015
I think the solution would be to refresh/reload the gdatetimepicker after changing the data attribute. Any ideas how to do this?
GreyHead 25 Nov, 2015
Hi whitemage,

I have a partial answer for you here
jQuery(document).ready(function(jQ){
  jQ('#text3').on('click', changeDate);

  function changeDate() {
    var date;
    date = jQ('#datepicker1');
    date.data('start_date', '16-11-2015');
  }
});
The changeDate function will change the date in the datepicker, the start date is saved in the data object attached to the datepicker input. But, when you then click in the datepicker box the first page behaves as if the date has not been changed - if you click forward a month then back again all is well.

I can't immediately see how to get round this - maybe starting with a month or year view would work? Otherwise I might try a different datepicker.

Bob
This topic is locked and no more replies can be posted.