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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CF LOOP Problems!?

Status
Not open for further replies.

mx3com

Technical User
Oct 29, 2000
9
0
0
CA
Hi All,

I am trying to use the CFLOOP command for a page on my site, but am having trouble pulling a value from my database. This is my code below:

<FORM NAME=&quot;Pages&quot;>
<SELECT NAME=&quot;PageNo&quot; SIZE=&quot;1&quot; onchange=&quot;go2()&quot;>
<CFLOOP INDEX=&quot;SectionPages&quot; FROM=&quot;1&quot; TO=&quot;#SectionPages#&quot;>
<CFOUTPUT>
<OPTION VALUE=&quot;#SectionNo#/#SectionNo#-#NumberFormat('#SectionPages#',&quot;00&quot;)#.jpg&quot;>#SectionNo#-#NumberFormat('#SectionPages#',&quot;00&quot;)#</OPTION>
</CFOUTPUT>
</CFLOOP>
</SELECT>
</FORM>

The '#SectionPages#' clause is a field in the database which contains the total number of pages for each section. For example, SectionNo &quot;GI&quot; contains 19 pages, SectionNo &quot;A&quot; contains 7 Pages, etc etc.

If I want the pull down menu list to show the correct number of pages in that specific section, the CFLOOP TO value should be the total number of pages in that particular section, which is why I am using the value of '#SectionPages#'.

I get an error from CF however saying it can't evaluate the expression?

Any ideas on what I am doing wrong?

Regards,

Jeff Aycan - MX-3.com
 
The problem you might be having is probably due to your NumberFormat syntax in your sample code, unless of course this is a typo. Also, although I noticed that there's '/' and '-' in your OPTION VALUE, i'm assuming you're not doing some math calculation here but to have the two characters in the value as it is.

There try this...

<OPTION VALUE=&quot;#SectionNo#/#SectionNo#-#NumberFormat(SectionPages,&quot;00&quot;)#.jpg&quot;>#SectionNo#-#NumberFormat(SectionPages,&quot;00&quot;)#</OPTION>

You don't need to enclose the value to be number formatted with NumberFormat with #s. Just refer to the value as it is.

Hope this helps.

Klotzki
 
If your having trouble getting the expected number of loop iterations, take a look at your <cfloop> you have the index variable having the same name as the to variable. The same variable can't hold 2 different values. Try renaming your index value to sectionpage_index (or whatever) and see if it doesn't help.

bankholdup
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top