使用POST类型表单在Submit按钮之后获取附加元素的值

我想在提交后获取附加元素的值。它附加了正确的名称属性,但我无法获取值

<script>
    <?php
        $options = '';
        while($searched_species_adding = mysqli_fetch_array($search_species_adding)){
            $name = $searched_species_adding['name'];
            $options = $options.'<option>'.$name.'</option>';
        }
        echo 'var options = "'.$options.'";';
    ?>
    var count=2;
    $( "#add-species" ).click(function() {
      var html=$("<tr id='species-"+count+"'><td><select name='species-"+count+"' class='form-control'>"+options+"</select></td><td><input id='species-num-"+count+"' name='species-num-"+count+"' class='form-control' type='number'></td></tr>");
        $("#species-container").append(html);
        $("#species-num-"+count).prop('required',true);
        count++;
        var wew = ($('tr',$("#wew").find('tbody')).length);
        $(".tr-num").remove();
        $("#species-container").append("<input class='tr-num' type='hidden' value='"+wew+"' name='tr_count'>");
        $(".tr-num").val(wew);
    });

    $( "#remove-species" ).click(function() {
        count--;
        $("#species-"+count).remove();
        var wew = ($('tr',$("#wew").find('tbody')).length);
        $(".tr-num").val(wew);
    });
</script>

上面是用于追加的脚本。 这是我提交后在表单中获取值的代码:

if(isset($_POST['add-delivered'])){

$requestor = $_POST['requestor'];
$org_office = $_POST['org_office'];
$address = $_POST['address'];
$date_pickup = $_POST['date_pickup'];
$location = $_POST['location'];
$planting_type = $_POST['planting_type'];
$tr_count = $_POST['tr_count'];
$species = '';
for($x = 1; $x <= $tr_count; $x++){
    $species = $species.$_POST['species-'.$x];
}

echo '<script>alert("'.$tr_count.'")</script>';

exit();

}

daxiguatao 回答:使用POST类型表单在Submit按钮之后获取附加元素的值

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169897.html

大家都在问