【发布时间】:2015-10-17 12:16:27
【问题描述】:
我有如下图所示的表格,我在其中从查询创建到数据库,每一行都有我想要的按钮,当 onclick 将是提示对话框(我使用 jquery 对话框小部件)
这是我创建表格的 php 代码
while ($fetch_dbsi_mhsw=mysql_fetch_array($query_dbsi_mhsw)) {
$no++;
echo" <tr>
<td>$no</td>
<td>$fetch_dbsi_mhsw[NIM]</td>
<td>$fetch_dbsi_mhsw[Name]</td>
<td style=\"text-align: center;\"><input name=\"bt_tambah_calon_wisudawan\" id=\"bt_tambah_calon_wisudawan\" type=\"image\" src=\"buttonTambah.png\" alt=\"Tambah\" align=\"middle\" width=\"20\" height=\"20\" /></td> </tr>";}
还有我的 jquery 代码
$(document).ready(function(){
$("#bt_tambah_calon_wisudawan").click(function(){
var value1 = $(this).closest('tr').find('td:eq(1)').text();
var value2 = $(this).closest('tr').find('td:eq(2)').text();
// Here's the text of the dialog box
var dialog = $("<div style='display: none'><p>Anda akan menambahkan "+value1 + " " + value2 + " sebagai calon wisudawan?</p></div>").appendTo("body");
// This is the button on the form
var form = $("#form_tambah_cl_wisudawan")
// The form button was pressed - open the dialog
$(dialog).dialog(
{
title: "Konvirmasi Penambahan Data",
dialogClass: "no-close",
width: 600,
modal: true,
buttons: {
"Tambah": function () {
// This will invoke the form's action - putatively deleting the resources on the server
$(form).submit();
$(this).dialog("close");
},
"Cancel": function() {
// Don't invoke the action, just close the dialog
$(this).dialog("close");
}
}
});
return false;
});
});
我的问题是当我单击第一行中的加号按钮时,将出现对话框(如图 2 所示)
但是为什么当我单击另一行中的加号按钮时,对话框没有出现,页面只是重新加载并且我的表格消失了。每当我单击一个加号按钮时,我想提示对话框。有什么帮助吗?
【问题讨论】:
标签: javascript php jquery html