I am using jQuery UI picker and I am wondering if it's possible when someone pick a date, it automatically redirect them to the URL like so:
index.php?date=2013-10-15
Here's the plug-in I am using.
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
Date: <input type="text" id="datepicker" />
1) What you need is window.location.href
, which is the used to redirect the page. You can customize way the window to opened.
2) Once you select the date in datepicker (onSelect
), you can combine the change
event as @T.J. Crowder said in his answer.
You can try like this
$("#datepicker")
.datepicker({
dateFormat: "yy-mm-dd",
onSelect: function(dateText) {
$(this).change();
}
})
.change(function() {
window.location.href = "index.php?date=" + this.value;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With