jquery datepicker won't submit inside a table

2019-09-02 04:28发布

问题:

I have a jquery datepicker which it appears won't submit when a date is chosen because it is inside a table. I suspect the table after reading the second answer here:

jQuery UI Datepicker Inline - submiting form on click

I have created an identical datepicker (different name) outside the table, and it will submit when a date is chosen. The form is outside the table.

Here is the code

$(function () {
  $("#txtSantaDate").datepicker({
    changeMonth: true,
    changeYear: true,
    dateFormat: 'dd/mm/yy',
    minDate: '06/12/2014',
    maxDate: '21/12/2014',
    onSelect : function() { $(this).parent('form').submit(); }
  });
});

I want the datepciker to stay in the table, but I need it to submit when a date is chosen - is there anything I can do?

****** NEW ******

Thanks for replies - you really wouldn't want to pick through the HTML, I have been able to pare it down to this example:

<!Doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
  <meta charset="utf-8" />

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/jscript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/jscript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" >

  $(function () {
    $("#txtTest").datepicker({
      changeMonth: true,
      changeYear: true,
      dateFormat: 'dd/mm/yy',
      minDate: '06/12/2014',
      maxDate: '21/12/2014',
      onSelect : function() { $(this).parent('form').submit(); }
    });
  });

</script> 
</head>

<body  >
<form id="frmBooking" name="frmBooking"  action="/booking/book_now.php#basecamp" METHOD="POST">
<table><tr><td><input type='text' ID='txtTest' name='txtTest' value='' size = '12' /></td></tr></table>

</form>
</body>
</html>