JQuery UI datepicker built-in getDate to select

How do I get the selected date from this to go through POST?

 <script>
    $(function() {
        $( "#datepicker" ).datepicker();
        var arrival = $("#datepicker").datepicker("getDate");
 });
</script>

And I get a calendar that works like this:

<div id="datepicker" class="demo"></div>

Because it is not an entrance, it is a DIV. I have this problem.
See: http://jqueryui.com/demos/datepicker/#inline

+3
source share
1 answer

The event collector fires an event when a date is selected. You have installed an event handler in a function that then calls $ .post internally.

See the date selection in the Event Selection section .

If you prefer to publish data in your arrival variable in your example, you simply use the jQuery $ .post function (or $ .ajax if you want more control over the Ajax configuration).

: :

$(function() {
  $( "#datepicker" ).datepicker( { 
      onSelect: function(date, picker){ alert(date); }
    } );
} )

datePicker , 'onSelect'. , .

+5

Source: https://habr.com/ru/post/1789803/


All Articles