【发布时间】:2020-09-03 13:15:52
【问题描述】:
我正在使用 cfloop 将动态表单值插入到会话结构中。我使用 reReplaceNoCase 来清理输入并且在尝试在 reReplaceNoCase 方法中使用动态表单字段名称时遇到了问题。我尝试了不同的命名方案,但无法确定语法。在发布的代码中,FORM.RTchoice[r] 失败并显示错误: Element RTCHOICE is undefined in a Java object of type class [Ljava.lang.String;.. 如何让表单字段递增“r”正确吗?
<cfloop index="r" from="1" to="#APPLICATION.theCount#">
<cfset a = StructInsert(SESSION.USER_OBJECT, "RTchoice#r#", "#reReplaceNoCase(FORM.RTchoice[r], "[^a-zA-Z0-9.,(\s)-]", "", "all")#", 1)>
</cfloop>
【问题讨论】:
-
那是因为 form.rtChoice 是一个字符串。所有表单变量都是简单值。为什么你认为它应该是一个结构体?
-
我从“动态表单字段名称”中假设 OP 意味着有名为
RTchoice1、RTchoice2等的表单字段。
标签: struct coldfusion cfloop