Datepicker Submit form when select date

2019-01-28 21:13发布

please help me, how can i edit my javascript to submit form after select a date

     Date: <div id="datepicker"></div>


    <form action='?data=$data' method='POST' enctype='multipart/form-data'></form>

        <script>
      $(function() {
        $( '#datepicker' ).datepicker( $.datepicker.regional[ 'it' ] );
        $( '#locale' ).change(function() {
        $( '#datepicker' ).datepicker( 'option',
        $.datepicker.regional[ $( this ).val() ] );

    });

  });
 </script>

1条回答
看我几分像从前
2楼-- · 2019-01-28 21:45

I found solution. You may rewrite code like this.

<form method='POST' enctype='multipart/form-data' id='formId'>
  <input type="text" id="datepicker"/>
</form>

$(document).ready(function() {
  $('#datepicker').datepicker({
       onSelect : function (dateText, inst) {
          $('#formId').submit(); // <-- SUBMIT
  }});
});

This code from another post

查看更多
登录 后发表回答