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!

Using ColumnList variable to populate list box

Status
Not open for further replies.

Speckly

Technical User
Jun 9, 2004
18
0
0
GB
Hi does anybody know how to populate a list box (named which_fields) with the column names of a table from a query (named database_fields)?

I have tried various things and the best I've done is create a list box with no column names in it using this code:

Code:
 <cfFORM name="DateForm" ACTION="Download.cfm" METHOD="post"><div align="center"><BR>
          <B>Select recordset type to download:</B><BR>  
		   <select name="which_fields" display= "label" required="yes">
		   <cfloop list="#database_fields.ColumnList#" index="MyColumnName">
		   <option value="#MyColumnName#"></option></cfloop>  </select>

where am I going wrong???

Thanks in advance for any help
 
Simple... so close...

Here ya go:
<option value="#MyColumnName#">#MyColumnName#</option>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
I'm sorry for being really basic but the system still doesn't seem to be finding the column name even when I add: #MyColumnName#...i just get a long drop down list with many repeated #MyColumnName#'s.

Any advice... or am I being really thick on a Friday afternoon trying to code?

My code again:

Code:
<cfFORM name="DateForm" ACTION="Download.cfm" METHOD="post"><div align="center"><BR>
          <B>Select recordset type to download:</B><BR><BR><BR>  
		   <select name="which_fields" display= "label" required="yes">
		   <cfloop list="#database_fields.ColumnList#" index="MyColumnName">
		   <option value="#MyColumnName#">#MyColumnName#</option></cfloop>  </select>

Cheers
 
You need <cfoutput> tags to be able to see the info.
Code:
<cfoutput>
<cfloop list="#database_fields.ColumnList#" index="MyColumnName">
           <option value="#MyColumnName#">#MyColumnName#</option>
</cfloop>
</cfoutput>



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
He's right too.

Can't believe I missed that.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 

Thanks that did the trick!!!

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top