使用Jquery动态生成的Checkbox组,而不是在表单提交后发布值

时间:2017-03-10 07:57:23

标签: javascript php jquery ajax post

我已经使用jquery动态生成了一些复选框,但是当我尝试通过POST发布所有选中的框时,他们没有被提交...

这是我的 jquery

 <script type="text/javascript">
    $(document).on('change', "#scheme_select", function(){

    var tag=$("#type").val();

    $.ajax({
    type: 'post',
    url: 'fetchcheck.php',
    data: {
    action : tag
    },
    success: function (response) {

    document.getElementById("scrl").innerHTML=response;
    }
    });

    });
    </script>

这是我的 fetchcheck.php

<?php
if(isset($_POST['action'] ))
{
include "dbconnect.php";

 $table = $_POST['action'];
 $find=mysql_query("SHOW COLUMNS FROM `".$table."` ");

 while($row=mysql_fetch_array($find))
 {

  echo "<input type='checkbox' name='pcheck[]' value='".$row['Field']."'>".$row['Field']."</input>";
  echo "<br>";
 }
 exit;
}
?>

这是我的 html 文件

<form action="reportr.php" method="POST">
                    <table id="sort" class="table table-bordered table-striped table-condensed">
                           <thead>
                               <tr>
                                   <th>SELECT</th>
                                   <th>TYPE</th>
                                   <th>SUB TYPE</th>
                                   <th>SCHEME</th>
                               </tr>
                           </thead>
                           <tbody>

                           </tbody>
                       </table>
                       <input type="hidden" id="count" name="count" value=""></input>
                       <button type="button" class="btn btn-primary" id="del">Delete Row</button> &nbsp;&nbsp;&nbsp;

                     </div>
                     <div id="check" class="col-sm-3 ds1">
<h3>OPTIONS</h3>
<div id ="scrl" class="scrl">
  <input type="checkbox" name="pcheck[]" value="dummy">dummy</input>
</div>
                   </div>
                       </div>
                     </div>
                   <input type="submit" class="btn btn-primary" value="GENERATE REPORTS" id="submitr" name="submitr">
</form>

0 个答案:

没有答案