I am trying to submit form when date is clicked on datepicker. I have managed to submit, but cannot pass chosen date to hidden field of the form. So, form submits, but date is not sent (
I am sure it must be simple to do, but I am not experienced with js, so any help is appreciated.
Here's the code:
<script type="text/javascript">
$(document).ready($(function(){
var $hiddenInput = $('#hiddenFieldID');
$('#datepicker').datepicker({ inline: true })
.bind('click', function(){ $('#myFormID').submit();})
.bind('hiddenFieldID',function(e, hiddenFieldID, $td) { $hiddenInput.val(hiddenFieldID.asString()); });
}));
</script>
<div id="datepicker"></div>
<form id="myFormID" action="index.php" method="GET">
<input type="hidden" name="date" id="hiddenFieldID" value="">
</form>
The
datepicker
actually has a few options to help you with this. Try the following:Visit the full API for more options and events related to
datepicker
: http://api.jqueryui.com/datepicker/I fought with this same issue. In my case, my began and ended inside a table. Moving the form outside the table fixed the issue.
Gene