[英]php jquery popup message box working in the while loop
php jquery弹出消息框在while循环中工作,但在显示所有条目相同地址的弹出地址字段中,任何人都可以告诉我我在哪里做错了,谢谢
HTML jQuery脚本
<script type="text/javascript">
$(document).ready(function() {
$('#button').click(function(e) {
$('#modal').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
});
</script>
HTML表格和PHP页面
<table>
$query1=mysql_query("select * from customers order by id desc");
while($row1=mysql_fetch_array($result))
{
?>
<tr>
<td><div align="center"><?php echo $row1['firstname']; ?></div></td>
<td><div align="center"><?php echo $row1['lastname']; ?></div></td>
<td><div align="center"><?php echo $row1['dob']; ?></div></td>
<td><div align="center"><?php echo $row1['email']; ?></div></td>
<td><div align="center"><a href="#" class="button">Address</a></div></td>
<td><div align="center"><?php echo $row1['phone']; ?></div></td>
<td><div align="center"><?php echo $row1['country']; ?></div></td>
<td><div align="center"><?php echo $row1['city']; ?></div></td>
</tr>
<Popup Start>
<div id="modal">
<div id="heading">
Sign Up! Customer's Address
</div>
<div id="content">
<p><?php echo $row1['address']; ?></p>
</div>
</div>
<Popup End>
<?php }?>
</table>
在HTML中
将此行更改为:
<td><div align="center"><a href="#" id="button">Address</a></div></td>
这个:
<td><div align="center"><a href="#" class="button">Address</a></div></td>
&
将此行更改为:
<div id="modal">
这个:
<div class="modal">
使用Javascript:
$('.button').click(function(e) {
$(this).closest('tr').find('.modal:first').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
尝试为所有这样的按钮提供唯一的ID
<td><div align="center"><a href="#" id="button_<?php echo $row1['id'];?>">
Address</a>
</div></td>
然后根据其按钮的ID值应用弹出按钮单击,并像
<script type="text/javascript">
$(document).ready(function() {
$("input[id^='button']").click(function(e) {
$('#modal').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.