我正在尝试向我的 cfgrid 添加搜索功能。但我得到一个“元素名称在 FORM 中未定义。错误”。第一次加载页面时,它会显示网格。但是在我按下搜索按钮后,就会出现错误。这是代码:
<form name="DropDown" method="post">
<!--- query DB for the first drop down list --->
<cfquery name="Getprocedures" datasource="caselogs">
SELECT distinct procedures.procedure_name, procedures.procedure_id
FROM case_logs inner join procedures
on procedures.procedure_id=case_logs.procedure_id
WHERE case_logs.trainee_id=#form.name#
</cfquery>
<cfform action="#cgi.script_name#" method="post">
<select name="Ddl_form" size="1">
<cfoutput query="Getprocedures">
<option value="#procedure_id#" <cfif isDefined('form.Ddl_form')> <cfif form.Ddl_form eq "#procedure_id#">selected</cfif> </cfif>> #procedure_name#</option>
</cfoutput>
</select>
Status
<select name="Ddl_status" size="1">
<option value="P"<cfif isDefined('form.Ddl_status')> <cfif form.Ddl_status eq "P">selected</cfif> </cfif>>In Progress</option>
<option value="S"<cfif isDefined('form.Ddl_status')> <cfif form.Ddl_status eq "S">selected</cfif> </cfif>>Submitted</option>
<option value="R"<cfif isDefined('form.Ddl_status')> <cfif form.Ddl_status eq "R">selected</cfif> </cfif>>Reviewed</option>
<option value="-1" <cfif isDefined('form.Ddl_status')> <cfif form.Ddl_status eq "-1">selected </cfif> </cfif>>All</option>
</select>
<input type="submit" name="search" value="Search">
</cfform>
<cfif isdefined('form.search')>
<cfquery name="qGetBooks" datasource="caselogs">
SELECT CASE_LOGS.performed_dt,CASE_LOGS.submitted_dt,procedures.procedure_name,hospitals.hospital_code,case_logs.status
FROM case_logs
inner join procedures on procedures.procedure_id = case_logs.procedure_id
inner join hospitals on hospitals.hospital_id = case_logs.hospital_id
WHERE case_logs.trainee_id=2 and case_logs.status='#Form.Ddl_status#' and case_logs.procedure_id=#FORM.Ddl_form#
</cfquery>
<cfelse>
<cfquery name="qGetBooks" datasource="caselogs">
SELECT CASE_LOGS.performed_dt,CASE_LOGS.submitted_dt,procedures.procedure_name,hospitals.hospital_code,case_logs.status
FROM case_logs
inner join procedures on procedures.procedure_id = case_logs.procedure_id
inner join hospitals on hospitals.hospital_id = case_logs.hospital_id
WHERE case_logs.trainee_id=2 and case_logs.status='P'
</cfquery>
</cfif>
<cfform name="gridform">
<cfgrid name="BooksGrid"
format="HTML"
selectmode="row"
query="qGetBooks"
title="Students"
insert="true"
insertbutton="Insert Book"
width="500">
<cfgridcolumn name="performed_dt" header="DatePerformed" />
<cfgridcolumn name="submitted_dt" header="SubmitedDate" />
<cfgridcolumn name="procedure_name" header="Procedure" />
<cfgridcolumn name="hospital_code" header="Hospital" />
<cfgridcolumn name="status" header="Status" />
</cfgrid>
</cfform>
这是错误:
The error occurred in C:/ColdFusion10/cfusion/wwwroot/Caselogs/Trainee/caselogs.cfm: line 10
8 : select distinct procedures.procedure_name, procedures.procedure_id from case_logs
9 : inner join procedures on procedures.procedure_id=case_logs.procedure_id
10 : where case_logs.trainee_id=#form.name#
11 : </cfquery>
12 :