coldfusioncfform

coldfusion problem with flash form binding : PART 2


I am not sure why this one gives me "undefined". the imgNames are there.

  <cfquery name="getArt" datasource="cfartgallery">
   select * from art where artid < 10
 </cfquery>
 <cfdump var="#getArt#">
 <cfform name="myform" width="620" height="750" format="Flash" timeout="100" preservedata="yes" wmode="transparent">    
<cfformitem type="script">
    function updateSelectedArt():Void{
      var elem;
      var imgName;
      var values = [];
      var total  = parseInt(myform.pickmany_total);
      for (var i = 1; i <= total; i++) {
        elem = _root["pickmany"+ i];
        imgName = _root["img"+ i];
          if (elem.selected) {
              values.push(imgName.value);
          }
      }    
      // 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/>
    <cfinput name="img#currentRow#" type="text" value="#largeImage#"><br/>
</cfoutput>
<cfinput type="hidden" name="pickmany_total" value="#getArt.recordCount#">
   <cfinput type="text" name="pickmany_selected"  value="" size="50">
  </cfform>

Solution

  • oopsie..

    it is supposed to be values.push(imgName.text);

    this works:

       <cfquery name="getArt" datasource="cfartgallery">
         select * from art where artid < 10
      </cfquery>
      <cfdump var="#getArt#">
      <cfform name="myform" width="620" height="750" format="Flash" timeout="100" preservedata="yes" wmode="transparent">    
    <cfformitem type="script">
        function updateSelectedArt():Void{
          var elem;
          var imgName;
          var values = [];
          var total  = parseInt(myform.pickmany_total);
          for (var i = 1; i <= total; i++) {
            elem = _root["pickmany"+ i];
            imgName = _root["img"+ i];
              if (elem.selected) {
                  values.push(imgName.text);
              }
          }    
          // 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/>
        <cfinput name="img#currentRow#" type="text" value="#largeImage#"><br/>
    </cfoutput>
    <cfinput type="hidden" name="pickmany_total" value="#getArt.recordCount#">
    <cfinput type="text" name="pickmany_selected"  value="" size="50">
     </cfform>