kya*_*kya 5 javascript php jquery
我有一个PHP代码,可以从数据库中创建一个列表.我从数据库中检索的项目之一是行ID.我在以下代码中创建列表:
<th>Cover Name</th>
<th>Sum Insured</th>
<th>Info</th>
<th style="width: 3.5em;"></th>
</tr>
</thead>
<tbody>
<?php while($row = mysql_fetch_array($query_set)) { ?>
<tr>
<td><?php echo $row['cover_name'] ?></td>
<td><?php echo 'R '.$row['sum_insured'] ?></td>
<td><?php echo $row['info'] ?></td>
<td>
<a href="cover-type.php?id=<?php echo $row['coverid']?>"><i class="fa fa-pencil"></i></a>
<a href="#myModal" onclick="<?php $coverid = $row['coverid'] ?>" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
调用的语法 #myModal
<a href="#myModal" onclick="<?php $coverid = $row['coverid'] ?>" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a>
Run Code Online (Sandbox Code Playgroud)
你可以看到锚#myModal和onclick
单击锚点后,我想传递$coverid给下面的myModal弹出窗口
<div class="modal small fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Delete Confirmation</h3>
</div>
<div class="modal-body">
<p class="error-text"><i class="fa fa-warning modal-icon"></i>Are you sure you want to delete the cover?<br>This cannot be undone.</p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
<a href="delete-cover.php?id=<?php echo $coverid ?>" class="btn btn-danger" >Delete</a>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的印象是我需要有一些形式隐藏的javascript变量
<a href="#myModal" onclick="<?php $coverid = $row['coverid'] ?>" role="button" data-toggle="modal"><i class="fa fa-trash-o"></i></a> and pass it to myModal window, but how do I do that ?
Run Code Online (Sandbox Code Playgroud)
data-id="< ?php $coverid = $row['coverid'] ?>" class="trash"id="modalDelete"在 JQ 中:
// on clik trash icon
$('.trash').click(function(){
//get cover id
var id=$(this).data('id');
//set href for cancel button
$('#modallCancel').attr('href','delete-cover.php?id='+id);
})
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/4j59z60e/4/
| 归档时间: |
|
| 查看次数: |
21101 次 |
| 最近记录: |