javascript - 一旦表格被转置,提交表格将不起作用
问题描述
我需要转置/旋转表格,以便更好地查看它,但是一旦我转置表格,提交按钮现在将不再起作用我有一个表格设置如下
<table id="tableID" width="200" border="1">
<tbody>
<tr>
<td>Date</td>
<td>Boxed;</td>
<td>Location</td>
<td>Quantity</td>
<td>Change;</td>
</tr>
<?php do { ?>
<tr><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<td><?php echo $row_get['Date']; ?></td>
<td><?php echo $row_get['Boxed']; ?></td>
<td><input name="Location" type="text" id="Location" value="<?php echo $row_get['Location']; ?>" size="7" /></td>
<td><input name="Quantity" type="text" id="Quantity" value="<?php echo $row_get['Quantity']; ?>" size="7" /></td>
<td><input name="Update" type="submit" value="submit" id="Update" />
<input name="id" type="hidden" id="id" value="<?php echo $row_get['id']; ?>" />
</p>
<input type="hidden" name="MM_update" value="form1" />
</form></td>
</tr> <?php } while ($row_get ->fetch()); ?>
</tbody>
</table>
在转置表脚本中:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script>
$( document ).ready(function() {
$("#tableID").each(function() {
var $this = $(this);
var newTransposedRow = [];
$this.find("tr").each(function(){
var i = 0;
$(this).find("td").each(function(){
i++;
if(newTransposedRow[i] === undefined) { newTransposedRow[i] = $("<tr></tr>"); }
newTransposedRow[i].append($(this));
});
});
$this.find("tr").remove();
$.each(newTransposedRow, function(){
$this.append(this);
});
});
});
</script>
更新数据库:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = "UPDATE Stock SET Location=?, Quantity=? WHERE id=?";
$Result1= $conn->prepare($updateSQL) or die(errorInfo());
$done = $Result1->execute([$_POST['Location'], $_POST['Quantity'], $_POST['Trade_price'], $_POST['id']]);
if ($done){
header('Location: mypage.php
exit();
}
}
在我使用/插入转置脚本之前,这一切都很好,知道是什么停止了更新吗?欢迎任何帮助
解决方案
推荐阅读
- palantir-foundry - 循环遍历表列表并使用表名保存到 csv
- python - python plotly fig.write_image() 没有响应
- amazon-web-services - 从 s3 部署包结构问题上传 cloudformation lambda 函数
- spring - Spring @Autowire on 方法
- websocket - 客户端在 apache 上断开连接并请求数据后,服务器正在自行发起 GET 请求
- jquery - Rails 6:link_to 方法::delete 不起作用
- r - 如何对 R 中每个唯一组的值求和
- webassembly - WebAssembly 使用 i64 作为分支条件
- html - 如何调整 Ngx-Gallery 预览图像宽度?
- javascript - 比较数组中的关键字值字段 - Javascript