EDIT:将标识符添加到动态生成的行中
EDIT: add an identifier to a dynamically generated row
我正在从数据库中删除两个表。有一个Javascript函数,它将Table2
中的一行添加到Table1
中。我一直在尝试从confirm_trade.php
页面上的Table1
获取数据,这样我就可以将其放入数据库,但不知道如何提取该行(item_id
)。我想把表格放在表格中可以让我通过$_POST
访问它们,但这不起作用。如何向jquery行添加标识符,以便在confirm
页面上抓取?
来自jQuery函数的附加行是我需要item_id的行。
function addto(obj)
{
var $row = $(obj).parents("tr");
var $table = $("#tradee");
var item_id = $row.find(".item-id").text();
var item_name = $row.find(".item-name").text();
var item_desc = $row.find(".item-desc").text();
var newTR = $("<tr><td>"+item_id+"</td><td>"+item_name+
"</td><td>"+item_desc+"</td></tr>");
$table.append(newTR);
}
表2:
<div id='fixedDiv'>
<form action="confirm.php" method="post">
<table align="center" id="Table2">
<tr><td>Other Item</td></tr>
<?php while($rowi =$item->fetch_assoc())
{?>
<tr>
<td>
<?php echo $rowi['item_id']; ?>
</td>
<td>
<?php echo $rowi['item_name']; ?>
</td>
<td><?php echo $rowi['item_description'];?></td>
</tr>
<?php } ?>
<tr>
<td><input type="submit" name="submit" value="Continue"/></td>
</tr>
</table>
</form>
</div>
<br>
表1:
<table align="center" id="Table1">
<tr><th>item_id</th>
<th>Cat_id</th>
<th>Name</th>
<th>Description</th>
</tr>
<?php while($row =$item_results->fetch_assoc())
{?>
<tr></tr>
<tr>
<td class="item-id"> <?php echo $row['item_id']; ?> </td>
<td><?php echo $cat_id = $row['cat_id']; ?> </td>
<td class="item-name"><?php echo $item_id = $row['item_name'];?></td>
<td class="item-desc"><?php echo $item_descrip = $row['item_description'];?>
</td>
<td><input type="button" class="added" onclick="addto(this)"
value="Add" />
<td><input type="button" class="removed" onclick="remove()"
value="Remove" >
</td>
</tr>
<?php } ?>
</table>
根据您的代码判断,您可以使用<input type="hidden" name="some_hidden_data" value="field-value">
。确保你也用<form method="post"></form>
包裹你的桌子
则CCD_ 10字段将被包括为$_POST[‘hidden_field_name’];
相关文章:
- 无法从 jQuery RSS Feed 中的 localStorage 动态替换类
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 动态分配GA增强型电子商务跟踪器
- onkeyup无法动态创建多个文本区域
- 使用javascript将动态表从一个html页面打印到另一个html页
- 如何使Javascript动态html表及其上的事件
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 如何在Bootstrap Modal中为动态点击生成的变量设置jade属性
- 如何使用javascript从主svg对象动态创建svg视图框
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 通过在Dojo mobile ViewController.openExternalView中动态更改打开同一外部视图的
- 如何在Google柱状图中动态添加行/列
- 困在逻辑中试图定位动态的东西
- 在动态创建的元素上获取对特定选择器的引用
- 如何动态插入jquery代码
- 使用Google Visualization动态调用构造函数
- 使用jQuery动态添加表并在其中动态添加行
- d3基于用户选择动态更新节点
- 生成动态 HTML,使用 JavaScript 更改名称值.错误:- 意外的字符串或标识符
- EDIT:将标识符添加到动态生成的行中