Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFLOOP adding exclamation marks

Status
Not open for further replies.

Arion23

IS-IT--Management
Mar 29, 2001
132
AU
Hi all, not sure if anyone can help out with this or not:

I've got some code that loops over an array to create some HTML that is then sent via CFMAIL:

Code:
<cfset Variables.Books = &quot;&quot;>
<cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;#BookCount#&quot;>
  <cfset Variables.Books = &quot;<b>Book Item: #i#</b><br>&quot;>
  <!--- Loop over array --->
  ...
</cfloop>

Now in most instances, this works fine, but occasionaly and exclamation point is added to the i variable, when i = 4.

Eg - When it is working properly, Variables.Books contains:
Code:
<b>Book Item: 1</b></br>
<b>Book Item: 2</b></br>
<b>Book Item: 3</b></br>
<b>Book Item: 4</b></br>
<b>Book Item: 5</b></br>

When the mysterious problem occurs, Variables.Books contains:
Code:
<b>Book Item: 1</b></br>
<b>Book Item: 2</b></br>
<b>Book Item: 3</b></br>
<b>Book Item: 4!</b></br>
<b>Book Item: 5</b></br>

It seems to be dependant on the values stored in the array that is referenced in the loop, but I can't seem to work out why it is doing this.

Any thoughts?
 
Well then, you need to find out what the values are in the array. Modify your code to this:
Code:
<cfoutput>
Bookcount=#HTMLEditFormat(BookCount)#<br>

<cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;#BookCount#&quot;>
  <cfset Variables.Books = &quot;<b>Book Item: #i#</b><br>&quot;>
  array[#HTMLEditFormat(i)#]=#array[i]#<br>
</cfloop>
</cfoutput>
The line I added inside the loop will show you the value of &quot;i&quot; as well as the value of the array. I suspect that there is a problem with BookCount. How did it get it's value?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top