• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfselect selected with bind

Guest
Aug 27, 2007 Aug 27, 2007

Copy link to clipboard

Copied

I have a cfselect that is being populated by cfc remotely, how do I have an option selected by default? Using the selected attribute does not work, nor does hardcoding an option.

Is there a way to define which option should be selected in the cfc results?

Code:
<cfselect name="propertyType" bind="cfc:/com/form.getPropertyTypes()" bindonload="true" ></cfselect>
TOPICS
Advanced techniques

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 27, 2007 Aug 27, 2007

Copy link to clipboard

Copied

I found a hokey solution by passing the value I want selected to the cfc in the bind and doing an arrayInsertAt to position 1 of the array.

if(len(pTypeSelected)){
arrayInsertAt(aPropertyTypes,1,arrayNew(1));
aPropertyTypes[1][1] = pTypeSelected;
aPropertyTypes[1][2] = pTypeSelected;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2007 Aug 27, 2007

Copy link to clipboard

Copied

good job!
but is it actually selected in the cfselect?
i mean, if it is just the first element in the select box, it is not
necessarily 'selected', as in: its value is the value of the
form.selectbox... or is it?

but even if not, i suppose you could always employ a little javascript
to make the first element in select box 'selected' on page load....
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 28, 2007 Aug 28, 2007

Copy link to clipboard

Copied

The first value in the list is selected by default if none are marked as 'selected'. As I said, this is hokey and there has to be a better way.

I have run into a situation where I have a multiple select box and I need multiple selections automatically selected.

Any ideas?

Anyone?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2007 Aug 28, 2007

Copy link to clipboard

Copied

kyle969 wrote:
> I have run into a situation where I have a multiple select box and I need
> multiple selections automatically selected.
>
> Any ideas?

i think binding will not let you do this...

but then again i do not think your multiple select will be the second
select in a chain of related selects, right? it is probably the first
(or the only) select box?

if so, then you could return a comma-delimited list of values (the ones
to be pre-selected) from your cfc, and then have a regular select
element populated with regular option elements which are inside a cfloop
to check if the value of current option element is in the list passed
form cfc, and set selected=selected if it is...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 18, 2007 Sep 18, 2007

Copy link to clipboard

Copied

LATEST
kyle969 wrote:
> The first value in the list is selected by default if none are marked as
> 'selected'. As I said, this is hokey and there has to be a better way.
>
> I have run into a situation where I have a multiple select box and I need
> multiple selections automatically selected.
>
> Any ideas?
>
> Anyone?
>

follow-up:

anyone still looking for solution to this:

good old fellas ray camden and tod sharp have solved it
here:
http://www.coldfusionjedi.com/index.cfm/2007/8/7/Selecting-default-items-using-ColdFusion-8s-AJAX-Co...

and here:
http://cfsilence.com/blog/client/index.cfm/2007/8/7/Selecting-Multiple-Default-Items-With-ColdFusion...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation