【发布时间】:2014-06-21 11:18:40
【问题描述】:
您好,我正在将 php 变量传递给 twitter boostrap 模态。但是当我单击模式内的链接时,我无法获得正确的 ID。请参阅下面的代码。 首先我创建了一个 foreach 函数,其中数据循环第二我创建了一个链接以显示模式第三我在模式内有操作链接,用户可以在其中更新、删除数据。我已经实现的是我可以将 php 的变量传递给模态操作,但是当我尝试其他行时它仍然显示相同的 id。
<table class="table table-condensed table-bordered table-striped volumes">
<thead>
<tr>
<th>ID</th>
<th>Director</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<?php
foreach ($natcco_members as $nattco) {
$id = $nattco['id'];
echo "<tr>
<td>".++$counter."</td>
<td>".$nattco['director']."</td>
<td><a href='#' class='b'>".$nattco['agent_name']."</a></td>
<td>".$nattco['address']."</td>
</td>";
?>
<!-- Modal HTML -->
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Choose your actions!</h4>
</div>
<div class="modal-body" align="center">
<a href='update_sub_agent.php?id=<?php echo urlencode(htmlspecialchars($id)) ?>' class='btn btn-success'><i class='icon-pencil'></i> Edit</a>
<a href='owner.php?id=".urlencode(htmlspecialchars($id))."' class='btn btn-info'><i class='icon-user'></i> Owner</a>
<a href='fla.php?id=".urlencode(htmlspecialchars($id))."' class='btn btn-warning'><i class='icon-list-alt'></i> FLA</a>
<a href='delete.php?id=".urlencode(htmlspecialchars($id))."' class='btn btn-danger'><i class='icon-remove'></i> Delete</a>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<?php "</tr>";
}
}
?>
</tbody>
</table>
【问题讨论】:
-
不要把你的 Modal 放在表格内容中
-
您好@Manwal 感谢,我把 放在我的结束 之外,但它不起作用。
-
你能粘贴渲染的 HTML 吗?
-
嗨@ICanHasCheezburger,请参阅pastebin.com/u1XnKZ5a
-
@JaysonLacson 渲染的 HTML 是您在浏览器上看到的输出。 右键->查看源代码
标签: php jquery twitter-bootstrap