Hello, I'm trying to build a simple table based on Units and Chapters, where the number of Units will vary, and where Units can contain a variable number of chapters, chapters increment from 1 to the total number. The table will eventually pull in additional data, but I thought I'd start small.
For example Unit1 Chapter1 Chapter2 Unit2 Chapter3 Unit3 Chapter4 Chapter5 Chapter6 Unit4 Chapter7 My difficulty seems to be how to get the chapters to increment when I try nested loops. I've been banging my head a while, and this is as close as I've gotten. <!--- Set Variables for Course Structure, key values are number of chapters in each Unit---> <cfset Unit=StructNew()> <cfset Unit.Unit1=1> <cfset Unit.Unit2=3> <cfset Unit.Unit3=5> <cfset Unit.Unit4=2> <cfset Unit.Unit5=2> <!--- Set up Loop for adding total chapters. unitNumber = number of chapters in course. ---> <cfset Units=StructCount(Unit)> <cfset unitNumber = 0> <cfloop index="i" From="1" To = "#Units#"> <cfset count=StructFind(Unit, "Unit#i#")> <cfset unitNumber = #UnitNumber# + count> </cfloop> <cfoutput> <table> <tr> <th> Unit Number </th> <th> Chapter Number </th> <td> </tr> <cfloop from="1" to="#Units#" index="i"> <tr> <td> <a href="Unit#i#.cfm">Unit#i#</a> </td> <td> <a href="Chapter#i#.cfm">Chapter #i#</a> </td> </tr> <cfif StructFind(Unit, "Unit#i#") GT 1> <cfset chapterNumber = i> <cfset count=StructFind(Unit, "Unit#i#")-1> <cfloop from="1" to = "#count#" index="j"> <cfset chapterNumber=1+chapterNumber> <tr> <td> </td> <td> <a href="Chapter#chapterNumber#.cfm">Chapter#chapterNumber#</a> </td> </tr> </cfloop> </cfif> <tr> <td> </td> </tr> </cfloop> </table> </cfoutput> Thanks, Wade Pettenger ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213877 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54