Coldfusion 使用逗号分隔的值Listach和issue
我使用ListEach函数以逗号分隔两个不同的值 像这样:Coldfusion 使用逗号分隔的值Listach和issue,coldfusion,coldfusion-11,Coldfusion,Coldfusion 11,我使用ListEach函数以逗号分隔两个不同的值 像这样: <cfscript> result = []; listEach(form.getselection, function(value, index) { switch (value) { case "-2": result.append(listLast(ListGetAt(form.get_items, index), "~"));
<cfscript>
result = [];
listEach(form.getselection, function(value, index) {
switch (value) {
case "-2":
result.append(listLast(ListGetAt(form.get_items, index), "~"));
break;
case "-1":
result.append(ListGetAt(getselectiontext, index,',',true));
break;
default:
result.append(value);
}
});
</cfscript>
因此,将两者连接起来,我希望得到如下值:
41.47,105.0000,450,455,25.84
但不知何故,getselectiontext
中的值给我带来了麻烦,我得到了以下错误:
以下信息仅供网站开发人员调试之用。
处理请求时出错
无效的列表索引3
在函数ListGetAt(list,index[,delimiters])中,索引3的值作为第一个参数无效(此列表有2个元素)。有效索引的范围从1到列表中的元素数。
The error occurred in C:/inetpub/wwwroot/myproject/secure/portal.cfm: line 56
54 : break;
55 : case "-1":
56 : result.append(ListGetAt(getselectiontext, index,','));
57 : break;
58 : default:
您的第二个列表{getselectiontext}包含2个项目,而在{getselection}中使用ListAch进行迭代的项目少于5个 在“-1”的情况下,您试图从索引3或索引4处的{getselectiontext}获取不存在的列表项
您需要查看提交的数据以及如何通过表单提交数据。我不确定是否理解
getselectiontext
有3项(包括空项)。当您在getselection
值的第三次和第四次迭代中时,您希望从getselectiontext
中获得第二次和第三次值吗?但在其他情况下,它确实听起来像是无法拾取第四个布尔参数。是的,似乎是不正确的,我不明白我认为我解决了什么问题,我实际上禁用了文本字段,没有任何值,所以我启用了它,并使用“includeempty”来yes
,它现在起作用了。正如我在上面的评论中所说的修复,我正在禁用一个我应该禁用的文本字段
The error occurred in C:/inetpub/wwwroot/myproject/secure/portal.cfm: line 56
54 : break;
55 : case "-1":
56 : result.append(ListGetAt(getselectiontext, index,','));
57 : break;
58 : default: