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 / Advanced Techniques / September 2007



Tip: Looking for answers? Try searching our database.

cfselect selected with bind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kyle969 - 27 Aug 2007 15:28 GMT
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>
kyle969 - 27 Aug 2007 15:47 GMT
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;
            }
Azadi - 28 Aug 2007 06:00 GMT
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....
Signature


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

kyle969 - 28 Aug 2007 16:20 GMT
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?
Azadi - 29 Aug 2007 05:27 GMT
>  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...

Signature

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

Azadi - 19 Sep 2007 06:54 GMT
> 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.
[quoted text clipped - 5 lines]
>
>  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-C
oldFusion-8s-AJAX-Controls


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


Signature

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

 
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



©2008 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.