我试图获得<td>
值:
<table id="MyTable" class="table">
<tbody name="MyTable" id="tbody">
<tr name="MyTable">
<td name="MyTable" width="35%">value 1</td>
<td name="MyTable" width="35%">value 2</td>
<td name="MyTable" id="td"><input type="button" class="form-control" value="Edit"></td>
</tr>
</table>
我想知道$_POST
是否可以获取该值
答案 0 :(得分:2)
要使用$_POST
获取您所指的值,您需要做两件事:
form
元素input
内使用td
标记,其中每个输入的属性值应该是您稍后要获取的值。此外,您需要将该表单发回服务器。
答案 1 :(得分:2)
<form action="to_something.php" method="post">
<table id="MyTable" class="table">
<tbody name="MyTable" id="tbody">
<tr name="MyTable">
<td name="MyTable" width="35%"><input type="hidden" name="td_1" value="value_1">value 1</td>
<td name="MyTable" width="35%"><input type="hidden" name="td_2" value="value_2">value 2</td>
<td name="MyTable" id="td"><input type="button" class="form-control" value="Edit"></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>
<强> to_something.php 强>
<?php
$td1 = $_POST['td_1'];
$td2 = $_POST['td_2'];
?>
答案 2 :(得分:0)
<form method="post" action="something.php">
<table id="MyTable" class="table">
<tbody name="MyTable" id="tbody">
<tr name="MyTable">
<td name="MyTable" width="35%"><input type="text" name="v1" value="value 1"></td>
<td name="MyTable" width="35%"><input type="text" name="v2" value="value 2"></td>
<td name="MyTable" id="td"><input type="button" class="form-control" value="Edit"></td>
</tr>
</table>
</form>
现在您可以使用变量$_POST['v1']
和$_POST['v2']
来获取它。