【发布时间】:2014-07-09 10:04:56
【问题描述】:
order.html.php 的代码:
<body>
<p> Place order</p>
<table>
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<form id="form1" action="" method="post" >
<tbody>
<?php $id = 0 ;foreach ($dataProduct as $productData): ?>
<tr>
<td><?php echo ++$id ; ?></td>
<td><?php echo $productData['productName']; ?></td>
<td><?php echo $productData['productPrice'];?></td>
<td><input type="number" name="<?php echo $productData['productId']; ?>"/></td>
</tr>
<?php endforeach; ?>
<div><input type="hidden" name="add" value="placeorder"/>
<input type="submit" value="Place Order"/>
<div>
</tbody>
</form>
</table>
</body>
开发者工具中呈现的dom是:
<body>
<p> Place order</p>
<div><input type="hidden" name="add" value="placeorder">
<input type="submit" value="Place Order">
<div>
</div></div>
<table>
<thead>
<tr>
<th>Item No.</th>
<th>Name</th>
<!--<th>Mrp</th>-->
<th>Price</th>
<th>Quantity</th>
</tr>
</thead>
<form id="form1" action="" method="post" ></form>
<tbody>
<tr>
<td>1</td>
<td>hp keyboard old</td>
<td>400</td>
<td><input type="number" name="1"></td>
</tr>
<tr>
<td>2</td>
<td>lenovo keyboard old</td>
<td>450</td>
<td><input type="number" name="2"></td>
</tr>
<tr>
<td>3</td>
<td>kaspersky antivirus</td>
<td>430</td>
<td><input type="number" name="9"></td>
</tr>
</tbody>
</table>
</body>
在 order.html.php 和生成的 dom 中查看提交的位置。 由于这个 dom 结构 order.html.php 无法提交驻留在输入字段中的值。
这是有相关问题的帖子,但不完全是这里所代表的内容, Retrieve data from HTML table to PHP
【问题讨论】:
-
您的 HTML 无效,这就是原因。
-
html 有效。现在看@think
-
不,这不是@devprashant。查看你的 HTML >>> 你不能在tad之后放置表单标签,你不能在关闭tr之后放置div
-
谢谢。这对我来说是新事物。 @想想
标签: php html html-table html-tableextract