3

だから私はこのコードを持っています:

<!-- New Array for my loop -->
<cfset filesArray = ArrayNew(1)>
<!-- index for loop -->
<cfset arrayIndex = 1>

<!-- When a user attaches a file jQuery attaches a
hidden input element to the DOM with an id of 'attachedFile(index)'
and a value of the file name. This loops over the form fields looking for input with
id of 'attachedFile(something)' and sticks it into my array-->
<cfloop collection="#FORM#" item="field">
    <cfif FindNoCase('attachedFile',field) IS 1>
        <cfset filesArray[arrayIndex] = field>
        <cfoutput>#filesArray[arrayIndex]#<br></cfoutput>
        <cfset arrayIndex = arrayIndex + 1>
    </cfif>
</cfloop>

<!-- I use this to sort my array, it outputs YES
so I know it works right up until here -->
<cfoutput>#ArraySort(filesArray,'text','asc')#</cfoutput>

<!-- Simple loop over my array so I can output what I'm creating, but I get an error
"ATTACHEDFILE1 cannot be converted to a number' -->
<cfloop array=#filesArray# index="i">
    <cfoutput>#filesArray[i]#</cfoutput>
</cfloop>

インデックスiの配列をどこで数値に変換しようとしているのかわかりませんが、これが私のコード全体です。誰かが問題を見ますか?配列は最後に問題なく出力されるはずですよね?

4

1 に答える 1

5

index in<cfloop>は、配列で使用する場合、数値ではありません。それは実際には配列内の要素です。

文言が意味をなさないことはわかっていますが、ドキュメントを確認してください。

于 2012-08-08T19:55:29.243 に答える