Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p><strong>Split the departure date in 3 and add each part to an input field</strong></p> </blockquote> <p>Looks like you already have the code written for this in the <code>onSelect</code> handler of the destination datepicker. Unfortunately, it looks like <code>setDate</code> <a href="http://bugs.jqueryui.com/ticket/6264" rel="nofollow">does not trigger that event</a>, and you cannot trigger it manually. What I would recommend is breaking that code out into a separate function that you can call from both places:</p> <pre><code>function splitDepartureDate(dateText) { var depSplit = dateText.split("-", 3); $('#alt-vertrek-d').val(depSplit[0]); $('#alt-vertrek-m').val(depSplit[1]); $('#alt-vertrek-y').val(depSplit[2]); } </code></pre> <p>Then change your departure datepicker <code>onSelect</code> handler to point to that function:</p> <pre><code>$('#vertrek').datepicker({ // Prevent selecting departure date before arrival: beforeShow: customRange, onSelect: splitDepartureDate }); </code></pre> <p>Lastly, call that function from your arrival's <code>onSelect</code> event handler:</p> <pre><code>/* snip: */ // Populate departure date field var nextDayDate = $('#aankomst').datepicker('getDate', '+3d'); nextDayDate.setDate(nextDayDate.getDate() + 3); $('#vertrek').datepicker('setDate', nextDayDate); // Manually call splitDepartureDate splitDepartureDate($("#vertrek").val()); </code></pre> <hr /> <blockquote> <p><strong>When the arrival-datepicker closes (onClose), the departure-datepicker should open automatically, defaulting to the date selected in point 1</strong></p> </blockquote> <p>This is just a matter of using the <code>onClose</code> event handler:</p> <pre><code>onClose: function() { $("#vertrek").datepicker("show"); } </code></pre> <p>Here's your updated example: <a href="http://jsfiddle.net/zXMke/" rel="nofollow">http://jsfiddle.net/zXMke/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload