admin管理员组

文章数量:1278920

Currently I'm using JQuery UI's datepicker range, and I've added some more javascript that should submit the form on the page when different form elements change.

This works on the drop down I've added, as well as the date picker input boxes if I enter dates manually and then click away.

However, if I click an input field for the datepicker, and the date chooser pops up, the form will not submit after choosing a date..

Its as if the input field didn't know a change occured..?

/

here is the code I'm using:

$(document).ready(function() {

                $('#from').change(function() {
                  document.myform.submit();
                });

            });
            $(document).ready(function() {

                $('#to').change(function() {
                  document.myform.submit();
                });

            });

Using the datepicker UI events, I've added the following code for testing but it isn't working.. any ideas?

$(document).ready(function() {

                $('#from').datepicker({
                   onClose: function() { alert('Yo yo!') }
                });

            });

Currently I'm using JQuery UI's datepicker range, and I've added some more javascript that should submit the form on the page when different form elements change.

This works on the drop down I've added, as well as the date picker input boxes if I enter dates manually and then click away.

However, if I click an input field for the datepicker, and the date chooser pops up, the form will not submit after choosing a date..

Its as if the input field didn't know a change occured..?

http://api.jquery./change/

here is the code I'm using:

$(document).ready(function() {

                $('#from').change(function() {
                  document.myform.submit();
                });

            });
            $(document).ready(function() {

                $('#to').change(function() {
                  document.myform.submit();
                });

            });

Using the datepicker UI events, I've added the following code for testing but it isn't working.. any ideas?

$(document).ready(function() {

                $('#from').datepicker({
                   onClose: function() { alert('Yo yo!') }
                });

            });
Share Improve this question edited May 31, 2011 at 20:43 Elliot asked May 31, 2011 at 20:15 ElliotElliot 13.8k29 gold badges83 silver badges120 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 1

The jQuery UI DatePicker has custom events, particularly the onSelect event, click the event's tab and it's at the bottom of the docs:

http://jqueryui./demos/datepicker/

Double check there are no JavaScript errors above the code you quoted.

If there are errors then the JavaScript code below these errors will not execute properly.

That is probably why the code you added to test did not work either.

The correct answer is here: jQuery datepicker, onSelect won't work

I hope it should be on focus . on click of date picker the focus will be in the text box where you have to show the date. so the event should be .focus()

http://api.jquery./focus/

http://api.jquery./focusout/

本文标签: javascriptUsing change() and a datepicker in jquery to submit a formStack Overflow