duanou9758
duanou9758
2013-07-03 17:52

为什么jquery没有传递post值

  • php
  • datetimepicker
  • jquery

I have a page with two forms on it. This shouldn't be a problem, but it is not working. My jquery looks like this:

$(document).ready(function()
        {
            $("table.jobs tbody tr td#ejob").click(function()
            {
                var $this = $(this);
                var col   = $this.text();
                var LeftCellText = $this.prev().text();
                $('#jobid').val(LeftCellText);
                if (col == '')
                alert("Please pick another column");
                else
                $('#jobUpdate').submit();
            });
            var now = new Date();
            var month = now.getMonth()+1;
            var day = now.getDate();
            var year = now.getFullYear();
            if (month<10){month='0'+month}
            if (day<10){day='0'+day}
            var now = month +"/"+ day + "/" + year;

            var calendarBox = $('#calDate');
            //$('#calDate').val(calendarBox.datetimepicker('getDate'));
            var thisone = $('#calDate').val(calendarBox.datetimepicker('getDate'));

            calendarBox.datepicker(
            {
                minDate:('setDate', '' , new Date()),
                defalt:calendarBox.val(now),

                onSelect: function (selectedDateTime)
                {
                    $('#calDate').val(calendarBox.datetimepicker('getDate'));
                    alert("Sendeing " + $('#calDate').val(calendarBox.datetimepicker('getDate')));
                    $('#calendarForm').submit();
                }
            });
        }
        );

and my forms look like this:

echo "<form id='calendarForm' action='view_rev8.php' method='POST'>";
echo "<table border='0' width='100%'class='calendarTable'>";
echo "<tr><td align='left'>Click on a job number to update or change job information</td>";
echo "<td align='right'></td>";
echo '<td align="right">Calendar: <input type="text" id="calDate" size="15" name"calDate"/></td></tr>';
echo "</table>";
echo "</form>";
//creates the form to post jobid for updateJobForm.php
echo'<form id="jobUpdate" action="../forms/updateJobForm.php" method="post">';
echo'<input type="hidden" name="jobid" id="jobid">';
echo '</form>';

The first function handles when a user clicks on a table item and submits the post value without a problem. The datepicker works and the form gets submitted, but i get the following error: Undefined index: calDate from the following page:

$pickedDate = $_POST['calDate'];
include_once("../php/job_class.php");
echo $pickedDate;

$obj=new  jobs();
echo "<div style='border:solid 1px '>";
foreach ($obj as $val)
{
echo "<pre>";
echo print_r($obj);
//echo $obj->jobInfo();
echo "</pre>";
echo "</div>";
}

Why is this not working? It is a simple post from a well defined form, and as far as I can see all fields are named consistently and accurately.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换