我有.cfm
个文件。这是在另一个.cfm
文件的“提交”按钮上调用的。但提交按钮单击会显示错误:Element TYPE_QUERY is undefined in FORM. error occurred in line 3
。正如您所看到的,我在标记中添加了.form
范围:
<cfset sdate = Form.s_date>
<cfset edate = Form.e_date>
<cfset type_query = Form.type_query>
<cfif type_query eq "query1">
<cflocation url="query1.cfm?fdate=#sdate#&edate=#edate#">
<cfelseif type_query eq "query2">
<cflocation url="query2.cfm?sdate=#sdate#&edate=#edate#">
<cflocation url="report_test.cfm">
</cfif>
答案 0 :(得分:3)
一些事情:
form.type_query
。 (您是否有名为type_query
的表单字段?)encodeForURL()
。)cflocation
,您永远不会重定向到report_test.cfm
。type_query
既不匹配“query1”或“query2”,也会抛出错误或重定向到其他页面。type_query
设置默认值。<--- Optional (7):
<cfparam name="form.type_query" type="string" default="query1">
--->
<cfif structKeyExists(form, "type_query")>
<cfif compareNoCase(form.type_query, "query1") EQ 0>
<cflocation url="query1.cfm?fdate=#encodeForURL(form.s_date)#&edate=#encodeForURL(form.e_date)#">
<cfelseif compareNoCase(form.type_query, "query2") EQ 0>
<cflocation url="query2.cfm?sdate=#encodeForURL(s_date)#&edate=#encodeForURL(e_date)#">
<cfelse>
<cfthrow type="Application" message="Invalid value for the form variable 'type_query'.">
</cfif>
<cfelse>
<cfthrow type="Application" message="The variable 'type_query' was not part of the form data.">
</cfif>