2010-01-10 54 views
0

我在cfwindow中加载了一些javascript。我点击一个按钮就可以调用javascript函数。下面是在cfwindow中加载的代码..当我点击一个按钮JS错误显示出来说:setVendorPayee没有定义 函数onclick(event){setVendorPayee(“126”,“sudheer”); }(点击clientX = 397,clientY = 139)当我真正具备的功能在里面......请帮助javascript doent在cfwindow呈现的页面中工作

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

回答

1

我做了一些研究你并不能找到与任何古怪或怪癖什么在使用onfin与cfinput。

想到的唯一想要尝试的就是将脚本块放在cfwindow内容之外。

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

+0

感谢您的信息..问题是,它使用onclick时在主页面中查找javascript函数,而不是在cfwindow的渲染页面中查找。所以我把脚本放在主窗口中,现在一切正常...... – krishna 2010-01-10 21:01:52

+0

我想这可能就是这样。奇怪的是,“渲染页面”似乎只是一组div标签,所以在技术上它都在同一个文档中。 – Kenny 2010-01-11 12:35:57

0

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