From: Rick on
How do you get the selecteditems from multiple selection on a cfselect on
flash remoting?

Any help would be most appreciated!!!

I have a cfselect in a flash form I want to have multiple selections for.
When I send the data over to the cfc ( I am using remoting) I do not get the
list of data from the data I send.

Here is what I am doing.

mlist is my cfselect and auto is the value field.

this is my call to the cfc.

myService.schcreatepa(mlist.selectedItems.auto,..................

I have tried this but it says it is not an array. I have tried string but I
get not data back.
<cfargument name="mlist" required="false" type="array" default="" />

I have tried looping over the list or use arraytolist but nothing seems to
work.



From: Rick on
If you want Oranges selected do this.

<cfselect name="client" size="1" required="yes" message="Please choose a
client" query="clients" value="username"
display="company" selected="Oranges"></cfselect>


"Wally Kolcz" <wkolcz(a)projectproofing.com> wrote in message
news:ebtp6s$806$1(a)forums.macromedia.com...
>I am using cfselect to populate a drop down list on a form. Is there a way
>to set the initially selected value from a database result?
>
> I.E. If the 1st query pulls and populates the list with: Apples, Oranges,
> Pears
> The 2nd query has the value of Oranges
> Then the form will show the Oranges initially selected.
>
> I have this so far:
>
> <cfselect name="client" size="1" query="clients" value="username"
> display="company" required="yes" message="Please choose a
> client"></cfselect>
>
> --
> Wally Kolcz
> Developer / Support
>


From: Sabaidee on
Rick has got it totally right. One things to keep in mind about <cfselect>:
- 'selected' attribute references the VALUE of the cfselect option, not
displayed text.
Thus, it must reference one or more valid items from the query column defined
in the 'value' attribute of cfselect tag. If your query used in your <cfselect>
returns id and title (i.e. 1-apples; 2-oranges), and <cfselect>'s 'value'
attribute is set to 'id' query column, then the value of 'selected' attribute
must be 1 or 2 (or both, comma-separated, for multiple select lists), and NOT
apples or oranges.
In many, if not most, cases your <cfselect>'s 'value' attribute will be set to
the 'id' column of your query, since you are likely passing the selections made
in your <cfselect> as parameters to the form's action page or insert them into
another table in the database. And in most cases you can not be 100% sure of
current 'id' of the item(s) you want pre-selected in your <cfselect>,
especially if the table queried to populate your <cfselect> is user-editable
(i.e. user can delete the existing 'apples' item from that database table, and
then add a new 'apples' item, which will have a new id).
In such cases it may be better, instead of using <cfselect>, to use a plain
html <select> and loop through the query to output <option> tags for it with
'id' as value and 'title' as displayed text. You can then use a <cfif>/<cfelse>
conditional construct to assign a selected state to a particular <option> tag
based on the tag's displayed text ('title' query column), not its value ('id'
query column).
Example:
<cfquery name="getFruits" datasource="dsn">
SELECT id, title FROM fruits ORDER BY id;
</cfquery>
let's say the query returns 3 rows (id-title): 1-apples, 2-oranges, 3-peaches.
you can then use
<select name="fruit_id" size="1">
<cfoutput query="getFruits">
<cfif getFruit.title is "Oranges">
<option value="#id#" selected>#title#</option>
<cfelse>
<option value="#id#">#title#</option>
</cfif>
</cfoutput>
</select>

The returned value of your selection in this <select> tag will be the selected
fruit's id (i.e. #form.fruit_id# will return 2 in the above example based on
default selection), but you are pre-selecting an item in the select list based
on the fruit's title.

 | 
Pages: 1
Prev: CFLOGIN
Next: cfselect and multilple selectsions