闪光形式装订的冷融问题:第2部分

时间:2011-02-03 16:48:32

标签: coldfusion cfform

我不确定为什么这个给我“未定义”。 imgNames在那里。

  <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 个答案:

答案 0 :(得分:1)

oopsie ..

它应该是values.push(imgName.text);

这有效:

   <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 :(得分:0)

这没有文字字段:

  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(",");
     }