admin管理员组文章数量:1335644
i want to use jquery UI's datepicker to trigger a POST that would then load information from the date picked on the datepicker from my database.
so i guess this is a two-part question
is there a way i can make it so the datepicker date, when selected, just gets passed into a POST, so someone would click on jan 1 2010 and it would automatically go to mysite?date=01012010 or something like that the way it is now the datepicker just updates a text box with the date, so upon clicking on jan 1 2010, the text box is populated with 01-01-2010
which brings me to part 2 if there is no way to do what i asked in part 1, is there a method that triggers an event on the text box being updated, that way i could just do
onTextUpdate{
redirect to - mysite?date=$whateverIsInTextBox
}
or something like that
please let me know if you have any solutions or ideas to do this, thanks a lot
i want to use jquery UI's datepicker to trigger a POST that would then load information from the date picked on the datepicker from my database.
so i guess this is a two-part question
is there a way i can make it so the datepicker date, when selected, just gets passed into a POST, so someone would click on jan 1 2010 and it would automatically go to mysite.?date=01012010 or something like that the way it is now the datepicker just updates a text box with the date, so upon clicking on jan 1 2010, the text box is populated with 01-01-2010
which brings me to part 2 if there is no way to do what i asked in part 1, is there a method that triggers an event on the text box being updated, that way i could just do
onTextUpdate{
redirect to - mysite.?date=$whateverIsInTextBox
}
or something like that
please let me know if you have any solutions or ideas to do this, thanks a lot
Share Improve this question asked Jun 18, 2009 at 18:58 J SiegalJ Siegal 171 silver badge4 bronze badges 2- Please please don't do this. I really hate it when people do a post back on something as fiddly as a datepicker. – Iain Holder Commented Jun 18, 2009 at 19:01
- 1 @lainMH is correct is is not from good usability perspective to post on a data select, what if the user chose a wrong date and wishes to change it – Rony Commented Jun 18, 2009 at 19:10
3 Answers
Reset to default 5You could do something like this if you don't want to use ajax:
$("#datepicker").datepicker({
onSelect: function(date, instance) {
window.location = "www.example./?date="+date;
}
});
And if you do:
$("#datepicker").datepicker({
onSelect: function(date, instance) {
$.ajax
({
type: "GET",
url: "www.example.",
data: "date="+date,
success: function(result)
{
//do something
}
});
}
});
use the OnSelect event of the date picker
$('id').datepicker({
onSelect: function(dateText, ins) { ... }
});
you can try other events of the datepicker control based on your requirement
There are a number of events attached to the jQuery datepicker widget; onSelect should cover point #1 above:
$('.selector').datepicker({
onSelect: function(dateText, inst) { ... }
});
In your case, you can use the $.GET or $.POST functions to pass the data to the server.
本文标签: javascriptjQuery Datepicker to Trigger a POSTStack Overflow
版权声明:本文标题:javascript - jQuery Datepicker to Trigger a POST - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742365520a2461191.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论