【发布时间】: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