使用jQuery添加的表单元素,但$ _POST无法识别

时间:2010-04-20 17:13:22

标签: php jquery

<script type='text/javascript'>
$(document).ready(function() {
 $("#specific_consultant_yes").click(function() {
$('.specific').show('slow');

$.post("<?php echo  $this->url(array('controller'=>'appointment', 'action' =>'available'),'default',true)?>",{app_date:$("#App_date").val(),consultant:$("#Consultants").val()} ,function(data){
$(".new").html(data);
});

 $("#App_date").change(function() {
$.post("<?php echo  $this->url(array('controller'=>'appointment', 'action' =>'available'),'default',true)?>",
                        {app_date:$("#App_date").val(),consultant:$("#Consultants").val()} ,function(data){
$(".new").html(data);
});
});

 $("#Consultants").change(function() {
$.post("<?php echo  $this->url(array('controller'=>'appointment', 'action' =>'available'),'default',true)?>",{app_date:$("#App_date").val(),consultant:$("#Consultants").val()} ,function(data){
$(".new").html(data);
});
});

});


 $("#specific_consultant_no").click(function() {
$('.specific').hide('slow');
});

});
</script>
  <form name='update_form' id='update_form' method='POST' action="<?php echo $this->url(array('controller' => 'appointment', 'action' =>'updatesave'));?>">

    <fieldset name='Appointment'>
                        <legend>New Appointment Details</legend>
                      <div class='field50Pct'>
                        <div class='fieldItemLabel'>
                        <label for=''>Specific Consultant</label>
                        </div>
                        <div class=fieldItemValue'>
                        <input type='radio' name='specific_consultant' id='specific_consultant_yes' value='yes'>Yes
                        <input type='radio' name='specific_consultant' id='specific_consultant_no' value='no'>No
                        </select>
                        </div>
                        </div>
                        <div class='clear'></div>
                        <div class='specific' style='display:none'>
                        <div class='field50Pct'>
                        <div class='fieldItemLabel'>
                        <label for=''>Appointment Date</label>
                        </div>
                        <div class=fieldItemValue'>
                        <select name='app_date' id='App_date'>
                        <?php
                        $today = time();
                        for($i = 0 ;$i < 15; $i++)
                        {
                        $date_t = date('d-M-Y',$today);
                        $date_v = date('d-m-Y',$today);
                        ?>
                        <option value="<?php echo $date_t ?>"><?php echo $date_t ?></option>
                        <?php
                        $today = $today+(1*24*60*60);
                        } ?>
                        </select>
                        </div>
                        </div>
                        <div class='field50Pct'>
                        <div class='fieldItemLabel'>
                        <label for=''>Consultant</label>
                        </div>
                        <div class=fieldItemValue'>
                          <select name='consultants' id='Consultants'>
                        <?php foreach($this->consultantlist as $consultantlist){ ?>
                        <option value="<?php echo $consultantlist->getId() ?>"><?php echo $consultantlist->getFirstName() ?>  <?php echo $consultantlist->getMiddleName() ?>  <?php echo $consultantlist->getLastName() ?></option>
    <?php } ?>
                        </select>
                        </div>
                        </div>

                        <div class='clear'></div>
                        <br/>
                        <div class='new'>

                        </div>
                        <div class='clear'></div>
                        <br/>
                        </div>
                        </fieldset>
                        <center><input type='submit' name='update_appointment' value='Update Appointment' onclick='return confirmSubmit();'></center>
                        </div>
                        </form>

和 available.phtml的代码类似于

<?php

                $afternoon_time = '11:00';
                $myresult  .=   "<input type='text' name='slotddd' value='hai'>";

echo $myresult;

?>

额外的表单元素正在被正确添加并且显示...但是当我提交表单时...元素在$ _POST中无法识别...如何解决此问题&gt;

1 个答案:

答案 0 :(得分:1)

“new”类的1项在哪里?它在表格内吗?如果它不在表格内,则不包括在内。

例如:

<form action="/post.php" method="POST">
  <input name="somename" value="somevalue"/>
</form>

不等于:

<form action="/post.php" method="POST">
</form>
<input name="somename" value="somevalue"/>