Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coldfusion 使用逗号分隔的值Listach和issue_Coldfusion_Coldfusion 11 - Fatal编程技术网

Coldfusion 使用逗号分隔的值Listach和issue

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), "~"));

我使用ListEach函数以逗号分隔两个不同的值

像这样:

<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: