下面的问题是一个难题,我还没有解决,但找到了一种方法来处理。我终于拆开了xref2.cfm并将它一次放回一行。我一做到这一点,表格范围就开始起作用了。代码中没有任何变化。所以它仍然是一个谜。
我有一组4个程序链接在一起,如下所示:
person1.cfm:这是来自另一个程序的调用和一个url参数basetab = Person。我专注于变量" fn"。
<cfif IsDefined('URL.basetab')>
<cfset basetab = URL.basetab>
<cfset perloc = URL.perloc>
<cfset fn = ''>
<cfset ln = ''>
<cfset eof = "no">
然而,也可以使用cfinclude进一步访问person1.cfm,在这种情况下,我依靠表单范围将fn传递回person1.cfm
<cfelseif IsDefined('form.fn')>
<cfset fn = form.fn>
<cfset ln = form.ln>
<cfset basetab = form.basetab>
<cfset perloc = form.perloc>
<cfset eof = form.eof>
</cfif>
但是,如果此处未定义URL范围和表单范围,则应在包含person1.cfm的程序中设置变量fn,因此此时应该很好地定义它。
... stuff ...
<form action = "person2.cfm" method = "post" ... other stuff>
<input type = "text" name = "fn" value = "#fn#">
.... more stuff....
... submit ...
</form>
person2.cfm:这是流程的下一步
... stuff ...
<cfset fn = form.fn>
<cfinclude template = "person1.cfm">
<form action = "xref1.cfm" method = "post" ... stuff >
<cfoutput>
<input type = "hidden" name = "fn" value = "#fn#">
</cfoutput>
.... stuff ....
.....submit ....
</form>
xref1.cfm这是下一步
... stuff ...
<cfset fn = form.fn>
<cfinclude template = "person2.cfm">
<form action = "xref2.cfm" method = "post" ... stuff >
<cfoutput>
<input type = "hidden" name = "fn" value = "#fn#">
</cfoutput>
.... stuff ....
.....submit ....
</form>
xref2.cfm最后一步,用累积的条目完成某些事情
.... stuff ...
<cfset fn = form.fn>
<cfinclude template = "xref1.cfm">
... no form ... other stuff ...
问题是在xref2.cfm中,变量fn没有在表单范围中被拾取。检查一下,我发现在xref2.cfm中根本没有定义form.fn。当事物级联回Person1时,未定义fn并在输入标记中抛出错误。
form.fn在person2.cfm和xref1.cfm中定义。但是当我们到达xref2.cfm时,它就消失了。我不懂为什么。有人可以向我解释为什么xref2.cfm中没有那个表单范围?
答案 0 :(得分:0)
我认为这是一个错字或什么的。