javascript在cfwindow呈现的页面中不起作用

时间:2010-01-10 18:14:54

标签: javascript coldfusion

我在cfwindow中加载了一些javascript。我点击一个按钮调用javascript函数。以下是cfwindow中加载的代码。当我单击一个按钮时,JS错误显示出来: setVendorPayee未定义 function onclick(event){setVendorPayee(“126”,“sudheer”); }(点击clientX = 397,clientY = 139)当我实际拥有该功能时...请帮助

<script type="text/javascript">
  function getRecords1(){ 
   return true;
  }
  function setVendorPayee(vendorID,vendorName) {
   if (ColdFusion.Window.getWindowObject('VendorPayeeSearch_CFWindow')){alert('hi');
    document.ExpenseForm.payeeField#url.row#.value=vendorName;
    document.ExpenseForm.payee_Person_ID#url.row#.value=vendorID;
    ColdFusion.Window.hide('VendorPayeeSearch_CFWindow');
   }
   else if (window.opener && !window.opener.closed) {  
    window.opener.document.ExpenseForm.payeeField#url.row#.value=vendorName;
    window.opener.document.ExpenseForm.payee_Person_ID#url.row#.value=vendorID;
    window.close();
            }  

  }
 </script> 

 <cfform name="VendorForm" id="VendorForm" method="post" onsubmit="getRecords1();">
  <table id="myTable" border="0" cellpadding="0" cellspacing="0" width="100%" class="noBorder">
   <cfif Arguments.query.RecordCount>
    <tr class="baseColorMedium">
     <td align="center" >&nbsp;</td>
     <td align="center" ><strong>Vendor Name</strong></td>
     <td align="center" ><strong>Address 1</strong></td>
     <td align="center" ><strong>Address 2</strong></td>
     <td align="center"><strong>City</strong></td>
     <td align="center" ><strong>State</strong></td>
     <td align="center" ><strong>Zip Code</strong></td>
     <td align="center" ><strong>Vendor Type</strong></td>
    </tr>
   <cfelse>
    Your search did not return any results. Please modify your search criteria 
   </cfif> 
   <cfloop query="Arguments.query" >
    <cfscript>
     if (Arguments.query.CurrentRow mod 2 EQ 0) {
      bgcolortoggle = "gridRowEven";
     }
     else { 
      bgcolortoggle = "gridRowOdd";
     }
    </cfscript>
    <tr class="#bgcolortoggle#">
     <td align="center"><cfinput type="button" name="btnSelect_#arguments.query.vendor_code#" value="Select" onClick ="setVendorPayee('#arguments.query.vendor_code#','#arguments.query.vendor_name#');" class="submitButton" /></td>
     <td align="center">#HTMLEditFormat(trim(ucase(arguments.query.vendor_name)))#</td>
     <td align="center">#HTMLEditFormat(trim(ucase(arguments.query.address_1)))#</td> 
     <td align="center">#HTMLEditFormat(arguments.query.Address_2)#</td>
     <td align="center">#HTMLEditFormat(arguments.query.city)#</td>
     <td align="center">#HTMLEditFormat(arguments.query.state)#</td>
     <td align="center">#HTMLEditFormat(arguments.query.zip_code)#</td>
     <td align="center">#HTMLEditFormat(arguments.query.vendor_type)#</a></td>
    </tr>
   </cfloop>
   <tr>
    <td width="100%" class="noBorder" colspan="8">&nbsp; 

       </td>
   </tr>
   <tr>
    <td width="100%" class="noBorder" colspan="8"> 
     <cfinput type="submit" id="btnSearch" name="btnAddNewVendor" value="Add Vendor" class="submitButton" />
       </td>
   </tr>
  </table>
 </cfform>

2 个答案:

答案 0 :(得分:1)

我为你做了一些研究,在使用带有cfinput的onClick时找不到与任何奇怪或怪癖有关的任何内容。

尝试尝试的唯一一件事就是将脚本块放在cfwindow内容之外。

我不确定这是否会有所作为,但这是我先尝试的。

答案 1 :(得分:0)

可能需要添加<cfajaximport tags="cfform">,看看是否有帮助。