Forums Forums Search & Filter Pro Default date input

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #102459

    Hi,

    I’m using date range post meta filter.

    It’s possible to set a default date in input? For example from ‘today’ to ‘+1 month’.

    Thanks.

    Trevor
    #102514

    I have done this one one of my sites, but you have to use javascript to add the date. The issues that I found was that the plugin does not see the field as populated from an auto update point of view, and you have to decided on the date format you will use to match what the form is expecting. This is the code I used (obviously your field names will be different). I set one date to today and one date to a fixed date:

    <script type="text/javascript">
    jQuery( document ).ready(function($){
      var now = new Date();
      var today = ('0' + now.getDate()).slice(-2) + '/'
                 + ('0' + (now.getMonth()+1)).slice(-2) + '/'
                 + now.getFullYear();
      jQuery('li:first-child input[name="_sfm_transportation_dummy_start_date[]"]').val(today);
      jQuery('li:last-child input[name="_sfm_transportation_dummy_start_date[]"]').val('31/12/2050');
    });
    </script>

    Where the first child is the ‘From’ and the last child is the ‘To’.

    Anonymous
    #103549

    Thanks works fine, but to avoid extra JS it would fantastic add a ‘default datepicker date’ field in Search and Filter plugin

    Trevor
    #103552

    This is likely to come with the next major release of the plugin, V3.0. I will close this for now.

Viewing 4 posts - 1 through 4 (of 4 total)