我正在处理简单的表格,我在表格中的每一行都有“添加”按钮和“编辑”选项。如果可能的话,我希望这与JQuery对话框一起使用。我的代码不起作用,我需要帮助。如果你能看一下,让我知道应该修改什么。提前致谢。
这是我的User.cfm代码:
SQLServer
这是我的User.cfc代码:
<!--- ******************** Start ******************** --->
<head>
<title>User Table</title>
</head>
<cfparam name="ActiveP" default="1">
<cfquery name="qryUser" datasource="UsersData">
SELECT UserID, Date, Name, Age,
Case when Active = 1 then 'Yes' else 'No' end as Active
FROM Users
<cfif ActiveP EQ 1>
WHERE Active > 0
</cfif>
ORDER BY Date DESC
</cfquery>
<div style="padding-bottom:10px;">
<span onClick="User()"><strong> Add User</strong></span>
</div>
<table id='gwTable'>
<thead>
<tr>
<th>Date</th>
<th>Name</th>
<th>Age</th>
<th>Active</th>
</tr>
</thead>
<tbody>
<cfoutput query="qryUsers">
<tr>
<td>#DateFormat(Date, 'mm/dd/yyyy')#</td>
<td>#Name#</td>
<td>#Age#</td>
<td>#Active#</td>
</tr>
</cfoutput>
</tbody>
</table>
<cfoutput>
<div id="dialog" title="User Record" style="display:none"/>
</div>
</cfoutput>
<!--- ******************** End Main Output ******************** --->
<script>
//Function to call AddUser in AjaxFunctions
function AddUser(tblRow){
var RowId = $(tblRow).attr('id');
objStuEvents = {};
var whObj = {"url":"/apps/User.cfc?method=getUser&returnformat=json"};
gwAjaxPost(whObj,{"UserID":RowId},showUsers);
}
//Showing all results from AjaxFunction
function ShowUser(whObj){
var numRecs = whObj.RECORDCOUNT;
if( numRecs == "0" )
$('#gwExisting').html("No records exist");
else
{
objStuEvents = whObj;
//Create Table
var tbl = "<tableid='gwTable'><thead><tr><th>Date</th><th>Name</th> <th>Age</th><th>Active</th></tr></thead>";
tbl += "<tbody>";
for(var i=1; i<=numRecs; i++)
{
var jsRec = whObj.DATA[i];
tbl += "<tr><td>"+jsRec.DATE+"</td>";
tbl += "<td>"+jsRec.NAME+"</td>";
tbl += "<td>"+jsRec.AGE+"</td>";
tbl += "<td>"+jsRec.ACTIVE+"</td></tr>"
}
tbl += "</tbody></table>";
//Call for JQuery dialog box with dialog id
$('#dialog').html(tbl);
//Setting of height and width for dialog box
$( "#dialog" ).dialog({
height: 400,
width: 600
});
}
}
</script>