尝试在管理页面上进行ColdFusion编辑和删除部分。可以选中复选框,然后编辑或删除所选用户。
以下是代码。
<td>
<input type = "text" name = "firstname" value = "#firstname#">
<input type = "text" name = "lastname" value = "#lastname#">
<input type = "text" name = "email" value = "#email#">
<input type = "text" name = "user_name" value = "#user_name#">
<input type = "text" name = "password" value = "#password#">
</td>
<td width="120">
<input type="checkbox" name="Edit" value="Edit"> Edit <br>
<input type="checkbox" name="Delete" value="#ID#"> Delete <br>
<input type="submit" name="submit" value="Submit Changes" id = "Submit">
<!-- Action Page-->
<cfif isDefined("FORM.Delete") AND #Form.Delete# NEQ "">
<cfquery datasource = "feic_test">
DELETE FROM UserLogin
WHERE username = <cfqueryparam value = "#FORM.username#"
cfsqltype = "cf_sql_varchar">
</cfquery>
</cfif>
代码尚未完成,但到目前为止我还没有。如何让它有两个复选框,一个用于编辑,一个用于删除,然后一旦单击提交按钮,就会采取行动编辑数据库上的用户名或删除它?
答案 0 :(得分:0)
<input type="radio" name="action" value="Edit"> Edit <br>
<input type="radio" name="action" value="Delete"> Delete <br>
<input type="submit" name="submit" value="Submit Changes" id = "Submit">
<!-- Action Page-->
<cfif isDefined("FORM.action") AND #Form.action# eq "Delete">
<cfquery datasource = "feic_test">
DELETE FROM UserLogin
WHERE username = <cfqueryparam value = "#FORM.username#"
cfsqltype = "cf_sql_varchar">
</cfquery>
<cfelseif isDefined("FORM.action") AND #Form.action# eq "Edit">
<!--- Edit code --->
</cfif>
答案 1 :(得分:0)
假设#username#是主键
目前,当您检查编辑时,您并没有推翻#ID#。我假设#ID是
您可能希望使用
等表单字段var prev = -1;
function bubbles(bi){
if (bi != prev){
// put the rest of your bubbles(bi) code put here
}
prev = bi;
}