Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamic drop-down within a query

1 view
Skip to first unread message

Matt R

unread,
Nov 6, 2002, 6:54:05 PM11/6/02
to
I am trying to make a dynamiclly-populated (and dynamically selected) drop down menu within another query, and I'm not sure how to do it. Here's what's going on:

-I query my database for the regular data (not for the drop-down)
-I have 10 records per page. Each record is actually a form which can be used to update that record.
-In each form, there needs to be this dynamic drop-down I'm talking about, so it can be individually set for each record.

I know how to query and output data, but I don't seem to be able to output a query within another output of a query. So (if any of that made sense :), how can I do this?

Thank you...

-Matt


cyberpunk

unread,
Nov 7, 2002, 9:40:17 AM11/7/02
to
another try I hope this helps (see attached code)
thanks
good luck and PLEASE let me know how do do it
kes aka Cyber punk
Innovative Tech Solutions
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Or similar to the answer below: with thanks to 4midori

<query name=my" datasource="thisdb">
select * from myTable
</cfquery>

<cfquery name="GetInterestCodes" >
select * from myOthertableTable (or the same,but using different criteria, you can even use the same query above using a filter for the choices if this is what you need)
</cfquery>

<FORM action="gonowhere" method="Post">
<CFoutput query="my">
(the out put you need)

<select name="InterestCode" (Multiple?)>
<cfloop query="GetInterestedCodes">
<CFIF GetInterestCodes.InterestID <!--- (the link ID field connecting the two outputs) ---> IS my.InterestID>
<option value="#GetInterestCodes.InterestID#">#GetInterestCodes.InterestID# (or other descriptive value)
<CFELSE>
</CFIF>
</cfloop>
</select>

</cfoutput>
<input name="Submit" type="submit" value="go">
</form>
</body>
</html>


4midori

unread,
Nov 7, 2002, 11:13:27 AM11/7/02
to
CFOUTPUT can be used to loop through a query, or CFLOOP.

But only CFOUTPUT can be used to <CFOUTPUT>#MyVar#</CFOUTPUT>

If I've already started a CFOUTPUT for something, but I need to loop through something inside that, I used CFLOOP.

Of course you can also used CFLOOP in other ways, like looping through a list:

<CFLOOP from="1" to="#ListLen(MyList)#" index="i">

(I think "ListLen" is valid, if not its another term.)


Ben Seigel | Web Developer
University of WI-Extension

cyberpunk

unread,
Nov 7, 2002, 6:14:25 PM11/7/02
to
Quite a lot!!! CFQUERIES are in reality arrays them selves. you can reference row elements by their row number say #people.Fname[5]# will give you thr first name from row 5.
In general using a CFQUERY vs a QUERY LOOP is more common and (i think) a little faster. The other thing you may want to check into is setting up queries as application variables in the application.cfm
see attached. if you do this you can query the query with little or no query executition time. (i know i'm listed as new, but ive been developing since the 2.0 release...ya I'm brag'n.)
<cfapplication clientmanagement="yes" sessionmanagement="yes" sessiontimeout="#createtimespan(0,0,1,0)#">
<!--- this would be your application.cfm file at the root cf directory --->
<CFIF ISDEFINED(application.myquery)>
<CFELSE>
<CFQUERY datasource="mydatasource" name="application.mostusedquery" cachedafter="#createtimespan(0,0,1,0)#">
select * from thattable
</CFQUERY>

</CFIF>

<!--- inyour code you just call the query output w/o hitting the database. if it times out it will just run before you call the output.--->


0 new messages