Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / General CF Topics / July 2004



Tip: Looking for answers? Try searching our database.

Dynamically Populate Select List

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hank - 22 Jul 2004 18:54 GMT
I'm trying to dynamically populate a select list but it's only
displaying the first item in the table.  Here's my query:

<cfquery name="readstatus" datasource="esidb1">
select status, name
from "typetbl - status"

</cfquery>

And my select code:

<cfoutput>
<select name=status>
<option value="#readstatus.status#">#readstatus.name#
</select>
</cfoutput>

Thanks!
Jon Cooper - 22 Jul 2004 21:01 GMT
Hank -

you have two options...

1) Use the built in CFSELECT tag (this will need to be within a CFFORM tag
rather than the standard FORM. eg:
   <CFFORM NAME="blah" ACTION="blah" METHOD="post">
   <CFSELECT NAME="status" QUERY="readstatus"  DISPLAY="name"
VALUE="status"></CFSELECT
   </CFFORM>

or

2) Use the code you already have but move the CFOUTPUTs so they are either
side of the <option... code and define the query as below:

<select name=status>
<cfoutput query="readstatus">
<option value="#status#">#name#
</cfoutput>
</select>

Either of these will get you sorted!

Jon Cooper
Visation Ltd

> I'm trying to dynamically populate a select list but it's only
> displaying the first item in the table.  Here's my query:
[quoted text clipped - 14 lines]
>
> Thanks!
Hank - 23 Jul 2004 15:17 GMT
ctrl+alt+delete - 24 Jul 2004 07:14 GMT
> I'm trying to dynamically populate a select list but it's only
> displaying the first item in the table.  Here's my query:
[quoted text clipped - 14 lines]
>
> Thanks!

You forgot to reference the query in your cfoutput tag. Try this:

<cfoutput query="readstatus">
<select name=status>
<option value="#readstatus.status#">#readstatus.name#
</select>
</cfoutput>
BobCobb - 24 Jul 2004 08:15 GMT
You would want to hope there weren't 50+ records, or that would look funny :-)

Bob

"ctrl+alt+delete" <thenetwerx@REMOVEmsn.com> wrote in message

> You forgot to reference the query in your cfoutput tag. Try this:
>
[quoted text clipped - 3 lines]
> </select>
> </cfoutput>
Jon Cooper - 24 Jul 2004 08:16 GMT
Ctrl...

Just to mention ..your solution wouldn't work because it would output a
select list for every record returned by the query!

see my notes above,

Jon

> > I'm trying to dynamically populate a select list but it's only
> > displaying the first item in the table.  Here's my query:
[quoted text clipped - 22 lines]
> </select>
> </cfoutput>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.