【问题标题】:Send a html table to php向php发送一个html表格
【发布时间】:2020-06-15 06:31:38
【问题描述】:

我在表单中创建了一个表,但这是唯一没有获取的内容。

使用 bootstable 创建此表。

表格和单元格的一些按钮控件使它们可编辑并且可以添加或删除行:

<table class="table table-bordered table-striped table-hover table-condensed  text-center" id="DyanmicTable" name="DyanmicTable">
    <thead>
        <tr>
            <th class="text-center">Repère</th>
            <th class="text-center">Quantité</th>
            <th class="text-center">Segments</th>
      <th class="text-center">Fixations latérales</th>
      <th class="text-center">Dalle à gauche</th>
      <th class="text-center">Commentaires</th>
            <th class="text-center">
        <button id="addNewRow" class="waves-effect waves-light btn">Ajouter une ligne</button>

            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
        </tr>
    </tbody>
</table>

用于获取表单并将其发送到 PHP 的脚本:

<script>
  const myForm = document.getElementById('msform');

  myForm.addEventListener('submit', function (e) {
    e.preventDefault();

    var formData = new FormData(this);

    fetch('test.php',{
      method: 'post',
      body: formData,
    }).then(function (response) {
      return response.text();
    }).then(function(text){
      console.log(text);
    }).catch(function(error) {
      console.log(error);
    });
  });

</script>

【问题讨论】:

标签: javascript php html validation bootstrap-4


【解决方案1】:

我建议在你的 PHP 代码中使用这个函数而不捕获错误

<? include('table.html') ; ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-12
    • 1970-01-01
    • 2022-09-26
    • 1970-01-01
    • 2017-07-16
    • 2021-09-28
    • 1970-01-01
    • 2018-06-10
    相关资源
    最近更新 更多