表单未传递整个字段值

时间:2013-10-16 06:51:06

标签: php html forms

这是我的表格

<form name='manual' method='POST' action='manual.php' onsubmit=\"return validateForm()\">

<input type='hidden' name = 'serial_no' value=2 > 

<input type='hidden' name = 'batch' value='' > 

<input type='hidden' name = 'course' value='' >

<input type='hidden' name = 'schedule_id' value=''>

<input type='text'  id='topic' name = 'topic'> 

<input type='text' id='start_date' name = 'start_date' >

<input type='text'  id='end_date' onclick=\"cal();\" name='end_date'>

<input type='submit' name = 'Add'  value='Add'> 

</form>

当我提交表格时

我得到了这个结果:

Array ( [serial_no] => 2 [batch] => [course] => [schedule_id] => [topic] => hai [Add] => Add )

我没有获得start_dateend_date

任何人都可以解释为什么这两个字段值没有传递。

这是我的代码..

<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="1"> 

<td colspan="5" style="background:#204562; color:#FFFFFF; font-size:20px">ADD SCHEDULE</td>  

< tr> < td> Batch: <?echo "$batch[batch_name]";?> <input type=hidden name=batch value=<?echo "$batch[batch_id];"?> > </td></tr>

<tr> <td> Course: <?echo "$course[course_name]";?> <input type=hidden name=course value=<?echo "$course[course_id];"?> > </td>  </tr>

<tr>
<th>Serial No.:</th><th>Topic </th><th>Start Date</th> <th> End Date</th> <th> Action </th></tr>


<?


$count=1; 

$serial=0;

if(isset($_POST['serial_no']))

{

        $serial=$_POST['serial_no'];

        $count=1;

}

$ret=pg_query($db,"SELECT * from schedule_topic where schedule_id=$schedule_id order by serial_no");

while ($row = pg_fetch_array($ret)) {


        echo "<tr>";

        echo "<form name='manual' method='post' action='schedule_manual.php'>";

        $serial=$row['serial_no'];

        echo " <td> $row[serial_no] <input type='hidden' size='3'  name = 'serial_no' value=$row[serial_no] > </td>";

        echo " <td>  $row[topic] <input type='hidden' size='20' id='topic' name = 'topic' value=$row[topic]> </td>";

        echo " <td>  $row[start_date] <input type='hidden' size='12' id='start' name = 'start'> </td>";

        echo "<td>  $row[end_date] <input type='hidden' size='12' id='end' onclick='cal();'name = 'end'> </td>";

        echo "<td>  <input type='submit' name = 'Add' value='Added' disabled > </td>";

        echo "</form>";

        echo "</tr>";

}

while($count!=0)

{


        echo "<tr>";

        $serial++;

        echo "<form name='manual' method='POST' action='schedule_manual.php' onsubmit=\"return validateForm()\">";

        echo " <td> $serial <input type='hidden' name = 'serial_no' value=$serial > ";

        echo "  <input type='hidden' name = 'batch' value=$batch[batch_id] > ";

        echo " <input type='hidden' name = 'course' value=$course[course_id] > ";

        echo " <input type='hidden' name = 'schedule_id' value=$schedule_id> </td>";

        echo " <td>  <input type='text' size='20' id='topic' name = 'topic'> ";

        $obj->br() ; $obj->span("class='err' id=t_err");

        echo " </td>";

        echo " <td>  <input type='text' size='10' id='start_date' name = 'start_date' > ";

        $obj->br() ; $obj->span("class='err' id=s_err");


        echo "</td>";

        echo "<td><input type='text' size='10' id='end_date' onclick=\"cal();\" name='end_date'>";

        $obj->br() ; $obj->span("class='err' id=e_err");

        echo "</td>";

        echo "<td><input type='submit' name = 'Add'  value='Add'> </td>";

        echo "</form>";

        echo "</tr>";

        $count--;

        $obj->show_error($errors);


}

$obj->bottom();

?>

<td colspan="5" align="center">

<form name='update' method='post' action='schedule_manual.php'>

<input type=hidden name=batch value=<?echo "$batch[batch_id]";?> >

<input type=hidden name=course value=<?echo "$course[course_id]";?> >

<input type=hidden name=id value=<?echo "$schedule_id"; ?>>

<input type="submit" value="PROCEED SCHEDULE" name="com" >

</form> 

</td>


</tr>

</table>



<script type="text/javascript">
window.onload = function(){
        new JsDatePick({
useMode:2,
target:"start_date" ,
dateFormat:"%d/%m/%Y"
});
};

function cal ()
{
        new JsDatePick({
useMode:2,
target:"end_date" ,
dateFormat:"%d/%m/%Y"
});
}

var chkF = new checkFormElm();             // object instance of checkFormElm()
// HERE register onblur event to form elements that must be validated with PHP via Ajax
document.getElementById('topic').onblur = function() { chkF.checkAjax(this); }
document.getElementById('start_date').onclick = function() { chkF.checkAjax(this); }
document.getElementById('end_date').onblur = function() { chkF.checkAjax(this); }

function validateForm()
{
        alert("hai");
        alert(document.forms["manual"]["start_date"].value);
var x=document.forms["manual"]["topic"].value;
if (x==null || x=="")
{
        document.getElementById('t_err').innerHTML = ' Empty topic';
        return false;
}
else
{
        document.getElementById('t_err').innerHTML = '';

}
if (!isNaN(x))
{
        document.getElementById('t_err').innerHTML = 'Invalid topic';
        return false;

}
else
{
        document.getElementById('t_err').innerHTML = '';
}

}


</script>

1 个答案:

答案 0 :(得分:0)

您的start_date和end_date缺少“value”属性。