Im trying to get the selected date of an inline jquery datepicker.I need to use selected date in Java code and not in JS.I tried to bind it to a hidden input but it didnt work, i only got null
.
html:
<div id='datepicker'></div> <input type="hidden" id="datepicker_send" name="datepicker_send"> <div>Free Appointments on <label id="selectedDate">:</label></div>
and js :
$(document).ready(function(){
$("#datepicker").datepicker({altField:'#datepicker_send'});
$("#datepicker").on("change",function(){
var selected = $(this).val();
$('#selectedDate').html(selected);
});
I tried
request.getParameter("datepicker_send");
and i only got null
. Do you have any idea?
Thank you
In your JS, try: var selected = $('#datepicker').datepicker('getDate');
instead of: var selected = $(this).val();
this will trigger the getDate function in the datepicker class to actually get the date.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.