我有一堆问题和答案,未回答的问题必须在顶部抛出错误消息,答案在数组中,如果未回答,则数组将值存储为未定义的数组元素。
我试图通过将元素转换为列表来检索元素的位置,但是在循环列表时丢失了空元素。当我用简单的循环循环它时:
<cfloop from ="1" to="#arraylen(currentinfo.answers)#" index="ele">
<cfset i = i+1>
<cfif not listlen(currentinfo.answers[ele],'-')><cfset j=#i#>#j#</cfif>
</cfloop>
我在下面收到错误:
Element 5 is undefined in a Java object of type class coldfusion.runtime.Array.
The error occurred in D:\sites\askseaton\sections\PSSurvey\Clients\tags\surveydisplay.cfm: line 194
192 : <cfloop from ="1" to="#arraylen(currentinfo.answers)#" index="ele">
193 : <cfset i = i+1>
194 : <cfif not listlen(currentinfo.answers[ele],'-')><cfset j=#i#>#j#</cfif>
195 : </cfloop>
196 : <div>Question(s)#j# must be answered to proceed further.</div>