Reputation: 325
So I have this code:
<!-- 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 don't know where I'm trying to convert my array at index i into a number, but this is the entirety of my code. Anyone see the problem? The array should output at the end no problem, correct?
Upvotes: 3
Views: 882
Reputation: 32905
index in <cfloop>
is not a number when used with array. It's actually the element in the array.
I know, the wording doesn't make sense, but check the doc.
Upvotes: 5