coldfusioncfform

coldfusion problem with flash form binding


i have the following :

 <cfquery name="getArt" datasource="cfartgallery">
   select * from art where artid < 10
 </cfquery>
 <cfform name="myform2" width="620" height="750"  timeout="100" preservedata="yes" wmode="transparent">
<cfoutput query="getArt">
<cfinput id="pickers#currentRow#" name="pickmany" type="checkbox" value="#artname#" >
<label for="pickers#currentRow#">#artname#</label> 
<br/>
</cfoutput>
<cfinput type="text" name="pickmany_selected"  bind="{pickmany}" size="50">
</cfform>

whenever you check a box, it adds to the "pickmany_selected" field.

now, i am trying to do the same behaviour with a flash form.

 <cfform name="myform" width="620" height="750" format="Flash" timeout="100" preservedata="yes" wmode="transparent">    
<cfoutput query="getArt">
<cfinput id="pickers#currentRow#" name="pickmany" type="checkbox" value="#artname#" label="#artname#"><br/>
</cfoutput>

</cfform>   

this breaks. it only works if i put name="pickmany#currentRow#":

  <cfform name="myform" width="620" height="750" format="Flash" timeout="100" preservedata="yes" wmode="transparent">    
<cfoutput query="getArt">
<cfinput id="pickers#currentRow#" name="pickmany#currentRow#" type="checkbox" value="#artname#" label="#artname#"><br/>
</cfoutput>
<cfinput type="text" name="pickmany_selected"  bind="{pickmany1}" size="50">
  </cfform>

what do i need to do for the flash form so that pickmany_selected binds correctly? in the last example, i cannot bind to a generic name. hate these flash forms.


Solution

  • it only works if i put name="pickmany#currentRow#":

    Yes, flash forms require all field names to be unique. Because of that, I suspect your goal is not possible with a bind. However, you could roll your own function and call it onClick. My flash skills are pretty rusty. But something along these lines:

    <cfform name="myform" width="620" height="750" format="Flash" timeout="100" preservedata="yes" wmode="transparent">    
        <cfformitem type="script">
            function updateSelectedArt():Void{
              var elem;
              var values = [];
              var total  = parseInt(myform.pickmany_total);
              for (var i = 1; i <= total; i++) {
                elem = _root["pickmany"+ i];
                  if (elem.selected) {
                      values.push(elem.label);
                  }
              }    
              // use whatever delmiter makes sense
              _root["pickmany_selected"].text = values.join(",");
           }    
        </cfformitem>
        <cfoutput query="getArt">
            <cfinput name="pickmany#currentRow#" type="checkbox" value="#artname#" onClick="updateSelectedArt()" label="#artname#"><br/>
        </cfoutput>
        <cfinput type="hidden" name="pickmany_total" value="#getArt.recordCount#">
        <cfinput type="text" name="pickmany_selected"  value="" size="50">
    </cfform>