macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: bind failed for cfselect

Subject: Re: bind failed for cfselect
From: Azadi
Date: Fri, 14 Dec 2007 08:50:47 +0700
Newsgroups: macromedia.coldfusion.cfml_general_discussion


when the page tries to bind your second cfselect (Activity) to the Office on, the Offcie cfselect does not have any data yet... so Activity can't bind to the value of Office select.

try putting the following in the <head> of your page.
this code is adapted from someone's blog (Ray Camden's? - can't recall now...) - i will try to remember and give proper credit.

IMPORTANT: the code below assumes your FORM's name="test". if you have changed the name of your form amke sure you change it on line 6 in the code below, too. Also don't forget to change [script] & [/script] to proper tags.

<cfajaxproxy bind="javascript:test({Office},'[#form.Office#]')">
[script]
var imfinished = false;
function test(x,val) {
   if(!imfinished) {
           var dd = document.forms.test.Office;
           valArr = ColdFusion.JSON.decode(val);
           for(var i = 0; i < dd.length; i++){
                  for(var j = 0; j < valArr.length; j++){
                         if(dd.options[i].value == valArr[j]){
                                dd.options[i].selected = true;
                         }
                  }
           }
           imfinished = true;
   }
}
[/script]

hth

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

<Prev in Thread] Current Thread [Next in Thread>