Re: Determining if a value exists in a query result

2004-04-09 Thread Austin Govella
Austin Govella wrote:

 I have a list of generic features.
 
 And I have a list of features assigned to a specific item.
 
 I want to print out the generic features with checkboxes
 next to them.
 
 If the item in question has been assigned one of the
 features, I would like the checkbox for that feature to be
 checked.
 
 In the input tag for the checkbox, what function should I be
 using to compare the feature_id to the query results?

This has taken me all day, but I think the break at lunch 
helped clear things up for me.

After querying the selected features, create an empty 
variable (it will eventually hold the list of features):

cfset variables.selected_features = 

Using cfoutput, add each of the selected features to the list:

cfoutput query=q_selected_features
	cfset variables.selected_features = 
listappend(variables.selected_features,#q_selected_features.feature_id#)
/cfoutput

If you output variables.selected_features, you'll see a 
comma delimited list of feature id's.

While ouputting the complete list of possible features, you 
add a cfif statement to the checkboxes:

input
	name=footnote
	type=checkbox
	value=
	cfif listfind(variables.selected_features, #feature_id#) 
IS NOT 0
		checked=checked
	/cfif
/

variables.selected_features is our list of currently 
selected features. feature_id comes from the full list of 
possible features.

This *is* the easy way to solve this, right?

--
Austin
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Determining if a value exists in a query result

2004-04-09 Thread Mark W. Breneman
That is very similar to the way I do it. 

I think you can skip the query loop by using valuelist():

cfset variables.selected_features = valuelist(q_selected_features.
feature_id)

Note you can simplify that cfif statement in the checkbox down to:

cfif listfind(variables.selected_features, feature_id) 

The above code *should* work the same as your code just a little simpler.



Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
Vivid Media
[EMAIL PROTECTED]
www.vividmedia.com
608.270.9770

-Original Message-
From: Austin Govella [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 09, 2004 3:26 PM
To: CF-Talk
Subject: Re: Determining if a value exists in a query result

Austin Govella wrote:

 I have a list of generic features.
 
 And I have a list of features assigned to a specific item.
 
 I want to print out the generic features with checkboxes
 next to them.
 
 If the item in question has been assigned one of the
 features, I would like the checkbox for that feature to be
 checked.
 
 In the input tag for the checkbox, what function should I be
 using to compare the feature_id to the query results?

This has taken me all day, but I think the break at lunch 
helped clear things up for me.

After querying the selected features, create an empty 
variable (it will eventually hold the list of features):

cfset variables.selected_features = 

Using cfoutput, add each of the selected features to the list:

cfoutput query=q_selected_features
cfset variables.selected_features = 
listappend(variables.selected_features,#q_selected_features.feature_id#)
/cfoutput

If you output variables.selected_features, you'll see a 
comma delimited list of feature id's.

While ouputting the complete list of possible features, you 
add a cfif statement to the checkboxes:

input
name=footnote
type=checkbox
value=
cfif listfind(variables.selected_features, #feature_id#) 
IS NOT 0
checked=checked
/cfif
/

variables.selected_features is our list of currently 
selected features. feature_id comes from the full list of 
possible features.

This *is* the easy way to solve this, right?

--
Austin

_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Determining if a value exists in a query result

2004-04-09 Thread Austin Govella
Mark W. Breneman wrote:
 I think you can skip the query loop by using valuelist():
 
 cfset variables.selected_features = valuelist(q_selected_features.
 feature_id)
 
 Note you can simplify that cfif statement in the checkbox down to:
 
 cfif listfind(variables.selected_features, feature_id) 
 
 The above code *should* work the same as your code just a little simpler.

Thanks a ton. I'm going to try the simplified version now.

Thanks,
--
Austin
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]