Forums

Datepicker default date

gomi 10 Jul, 2015
:cry:
Hello i'm very confused...

I have two datepicker fields "anfahrt" and "abfahrt"

I need in the anfahrt field the date of tommorow and in the abfahrt field the date of tommorow + one day as default value.

I am using in in the start_date field of "anfahrt":

<?php $d = new DateTime('tomorrow'); echo $d->format("d.m.Y"); ?>


and load js in the setup:

jQuery(document).ready(function($){
$("#abfahrt").data("start_date", '<?php $d = new DateTime('tomorrow'); echo $d->format("d.m.Y"); ?>');
});


Now i can see in the datepicker for abfahrt tommorow selected. but i need to see it in the form also
And i need the same f the start_date of abfahrt (tommorow + one day) and also as defualt value.

I read the faq and the form for hours now but it won't work - can somene help me?

😢
gomi 10 Jul, 2015
Uh šŸ˜€ i think i got it - please correct me if i am wrong šŸ˜‰

I have two datepicker fields - a registration form, one for arrival, one for departure.

The earliest arrival is the next day - and the earliest departure is one day after the arrival .

In the first field (arrival) anfahrt (fieldname = anfahrt, field-id=anfahrt) i put following code in the advanced section "start date":

<?php $d = new DateTime('tomorrow'); echo $d->format("d.m.Y"); ?>


in the onload section i create this load js script code:

jQuery(document).ready(function($){
$("#anfahrt").data("start_date", '<?php $d = new DateTime('tomorrow'); echo $d->format("d.m.Y"); ?>');
});


to show this default-date in the field i put this custom-code in the onload section:

<?php
if ( !isset($form->data['anfahrt']) || !$form->data['anfahrt'] ) {
  $form->data['anfahrt'] = date('d.m.Y', strtotime('+1 days'));
}
?>


for the next field (departure) abfahrt (fieldname = abfahrt, field-id=abfahrt) i put in the following code in the advanced section "start date":

<?php $d = date('d.mY', strtotime('+2 days); echo $d->format("d.m.Y"); ?>


in the onload section i create this load js script code:

jQuery(document).ready(function(chronoQ){
chronoQ("#abfahrt").data("start_date", "<?php echo date('d.m.Y', strtotime('+2 days')); ?>");
});


to show this default-date in the field i put this custom-code in the onload section:

<?php
if ( !isset($form->data['abfahrt']) || !$form->data['abfahrt'] ) {
  $form->data['abfahrt'] = date('d.m.Y', strtotime('+2 days'));
}
?>



My question now is:

is the script correct or is there a better way?

Thank you šŸ™‚
gomi 10 Jul, 2015
Ah 😲 there's a error in logic....

Of course i need in the departure date the actual date from "anfahrt">(arrival) + 1 day.
I think that's a "on date selected" action..

No idea how this works 😢 can someone help?
gomi 17 Jul, 2015
No one can help me ?`😲
Max_admin 17 Jul, 2015
Hi,

Where do you put this code ? it should be in the "on load" and before the "html" action.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.