If I want to display the JQUERY UI datepicker inline by attaching it to a DIV like $("div#someID").datepicker()
- how do I access the chosen date? I assume if it's not bound to an INPUT
then it won't be submitted with the form.
I guess as a followup, if I need to bind it to an INPUT element, is there a way to control the positioning of the datepicker relative to the INPUT element? If I wanted the datepicker to appear above or to the side of the element rather than below it, how would I do that?
Forgive me if this answer is somewhere really obvious.
If you want to get the date when the user selects it, you can do this: $("#datepicker"). datepicker({ onSelect: function() { var dateObject = $(this). datepicker('getDate'); } });
$(document). ready(function () { $("#datepicker"). datepicker({ onSelect: function (dateText, inst) { var date = $(this). val(); alert(date); } }); });
If you want to get the date when the user selects it, you can do this:
$("#datepicker").datepicker({ onSelect: function() { var dateObject = $(this).datepicker('getDate'); } });
I am not sure about the second part of your question. But, have you tried using style sheets and relative positioning?
You can use the getDate
method:
var d = $('div#someID').datepicker('getDate');
That will give you a Date object in d
.
There aren't any options for positioning the popup but you might be able to do something with CSS or the beforeShow
event if necessary.
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