Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
EdmondsM #1
CFLoop can't count??
Hi All, what is wrong with the following code. All it is supposed to do is
count the records, take the total number of records list them 1 - 10 in a
dropdown box. But I am getting everything but that.
<cfform action="" method="post">
<cfloop index="i" from="2" to="#workFlow.recordCount#" step="1">
<cfoutput>
<cfselect name="sequence#i#" query="workFlow" display="ID" value="ID">
<option value=""></option>
<option value="#i#">#i#</option>
</cfselect>
</cfoutput><br />
</cfloop>
</cfform>
Thanks in advance.
Maurice
EdmondsM Guest
-
cfloop
The goal is to insert a record into table 'atd', which contains a document id and an associate id, for each document (38) and associate (150). So... -
Cfloop..
I am trying to loop over a list: <cfquery name="updsyllabus" datasource="#arguments.syl.dsn#"> UPDATE #arguments.syl.tname# SET <cfloop... -
count backwards with cfloop
hey everyone, i'm trying to list some bits of information by year, starting with the current year, and need to do a <cfloop> to do this. when i... -
count cfloop query
How can I display the number of times a query loops? Example: <cfloop query="countthis"> ?? </cfloop> So, if the query produced 10 results,... -
SIMPLE Question! - Count <cfloop>
How can I display the number of times a query loops? Example: <cfloop query="countthis"> ?? </cfloop> So, if the query produced 10 results,... -
-
philh #3
Re: CFLoop can't count??
With this code, you should be getting #workFlow.recordCount#-1 select boxes.
What do you want to display? Just the numbers? The content of the query?
One select box? n select boxes? What do you mean by "anything but"? Can you
provide a sample of the output, and a sample of how you want it to look?
philh Guest
-
EdmondsM #4
Re: CFLoop can't count??
Hey Phil, there are a total of 15 records in the db. I am using a loop becasue
if a record gets deleted I don't won't my dropdowns to be number like 123568.
So using a cfloop will give me the total number of records. Then in each
dropdown, I want to display 1 - 15 (or whatever the total is) but behind the
sense, each number has it's own ID. Each ID has a name associated with it.
That name is going to be displayed next to each select box as a description for
the select box. Make sense??
EdmondsM Guest
-
EdmondsM #5
Re: CFLoop can't count??
tkrussel, the cfslect has to be in the cfloop becasuse I need a select box for each record in the db.
EdmondsM Guest
-
EdmondsM #6
Re: CFLoop can't count??
Phil, the purpose ofr the numbered dropdowns is so the user can put them in order, from 1 to whatever the total number if items there are in the db.
EdmondsM Guest
-
Syncopation #7
Re: CFLoop can't count??
It is hard to understand what you're looking for. If you want one select box
with your records listed, do this:
<cfselect name="records">
<cfloop from ="1" to="#arraylen(myRecordsArray)#" index="i">
<option value="#myRecordsArray[1]#">#myRecordsArray[2]#</option>
</cfloop>
</cfselect>
If you're displaying one of these for each of your items listed form the
database, include the above code in another cfloop like this:
<cfloop from ="1" to="#arraylen(myRecordsArray)#" index="m">
Record Number <cfoutput>#m#</cfoutput>:
<cfselect name="records">
<cfloop from ="1" to="#arraylen(myRecordsArray)#" index="i">
<option value="#myRecordsArray[m][1]#"
<cfif i EQ m>selected</cfif>>#myRecordsArray[m][2]#</option>
</cfloop>
</cfselect>
</cfloop>
Syncopation Guest
-
philh #8
Re: CFLoop can't count??
So you want the user to be able to "rank" or order the importance of the
records? How are you going to relate the choice back to the record? You
shouldn't depend on the natural order of the record in the table. You're going
to have to have some way to associate the user's choice with the specific
record they're ranking, and that is usually done with the primary key.
So, if you have a primary key, it should be included in the name of the
CFSELECT object, so you can more easily associate the chosen value with the
record it's intended for.
<cfform action="" method="post">
<cfoutput query="workFlow">
<cfselect name="sequence#primarykeyfieldvalue#" query="workFlow" display="ID"
value="ID">
<option value=""></option>
<cfloop index="i" from="2" to="#workFlow.recordCount#" step="1">
<option value="#i#">#i#</option>
</cfloop>
</cfselect>
</cfoutput>
</cfform>
HTH,
philh Guest
-
EdmondsM #9
Re: CFLoop can't count??
Hi Phil, your solutions worked with a few tweeks.
Thanks for your help.
EdmondsM Guest



Reply With Quote

