0

我不确定为什么这个给我“未定义”。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>
4

2 回答 2

1

哎呀。。

它应该是 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>
于 2011-02-03T16:51:54.237 回答
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(",");
     } 
于 2011-02-03T22:26:01.567 回答