coldfusion problem with flash form binding : PART 2

249 views Asked by At

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>
2

There are 2 answers

4
KFNinja On BEST ANSWER

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>
1
KFNinja On

this is without the text field:

  function updateSelectedArt():Void{
       var elem;
       var imgName;
       var values = [];
       var imgArray = [];
       <cfoutput query="getArt">
        imgArray[#getArt.currentRow#] = '#getArt.largeImage#';
       </cfoutput>
       var total  = <cfoutput>#getArt.recordCount#</cfoutput>;
       for (var i = 1; i <= total; i++) {
           elem = _root["pickmany"+ i];
           imgName = _root["img"+ i];
           if (elem.selected) {
                values.push(imgArray[i]);
            }
       }    
       _root["pickmany_selected"].text = values.join(",");
     }