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.