gpt4 book ai didi

JavaScript 函数未定义错误(但已定义)

转载 作者:太空狗 更新时间:2023-10-29 13:47:55 25 4
gpt4 key购买 nike

我有一个在模糊时触发的 JavaScript 函数。奇怪的是,我第一次运行它时它运行良好,从那以后我一直收到一个错误,提示 JavaScript 函数未定义 - 然后它停止运行。我在谷歌上搜索过类似的问题,但没有任何建议能够解决问题。 Asp.Net 3.5 Webforms,如果重要的话。我已经包含了一些可能与问题无关的额外函数和代码行。我遇到的问题与大型函数 updateFiscalGrid 有关。绑定(bind)到事件的 HTML 位于函数下方。

<%@ Page MasterPageFile="~/MasterPages/NPRPage.Master"  CodeBehind="NPRFundingApplication.aspx.cs" Inherits="Tea.Hcf.Web.Secured.NPRFundingApplication" AutoEventWireup="true" Language="C#" EnableEventValidation="true" MaintainScrollPositionOnPostback="true" %>

<%@ Register TagPrefix="ew" Namespace="eWorld.UI" Assembly="eWorld.UI" %>
<%@ Register TagPrefix="hcf" Namespace="Tea.Hcf.Web" Assembly="Tea.Hcf.Web" %>
<%@ Register Src="../Controls/NpCdnSearch.ascx" TagName="NpCdnSearch" TagPrefix="np1" %>
<%@ Register Src="../Controls/NpStudentRoster.ascx" TagName="NpStudentRoster" TagPrefix="np2" %>

<script type="text/javascript" language="javascript">
//<![CDATA[

function showMaxWin(nUrl) {
var h = 600;
var w = 800;
var features = 'resizable=1, width=' + w + ', height=' + h + ', top=0, left=0';
NewWin = window.open(nUrl, 'NewWin', features);
}

function dateChangedCallback() {
updateSubTotals();
}

function updateFiscalGrid(){
var RelatedServicesCost = document.getElementById('<%= RPCB_SUPP_SVCS_SUBTOTAL3.ClientID %>').value;
var ResidentialCare = document.getElementById('<%= RPCB_RES_SVCS_SUBTOTAL3.ClientID %>').value;
var TotalCostforResPlacement = document.getElementById('<%= TotalResidentialPlacement.ClientID %>').value;
var SetAside = document.getElementById('<%= rblSetAsideMet.ClientID %>').value;
var LocalTaxSubtraction = document.getElementById('<%= LocalTaxShareSubtraction.ClientID %>').value;
var IDEABRelatedServiceCost = document.getElementById('<%= RelatedServicesSetAside.ClientID %>').value;
var IDEABDiscretionaryServicesCost = document.getElementById('<%= RelatedServicesDiscretionary.ClientID %>').value;
var IDEABREsidentialCare = document.getElementById('<%= ResidentialCareSetAside.ClientID %>').value;
var IDEABDiscResCare = document.getElementById('<%= ResidentialCareDiscretionary.ClientID %>').value;
var StateFSP = document.getElementById('<%= TotalEducationServices2.ClientID %>').value;
var Discretionary = document.getElementById('<%= DiscretionaryTotal.ClientID %>').value;
var IDEABAward = document.getElementById('<%= IdeaBAward.ClientID %>').value;
if(SetAside = '0'){
Discretionary = LocalTaxSubtraction + IDEABRelatedServiceCost + IDEABDiscretionaryServicesCost + IDEABREsidentialCare + IDEABDiscResCare;
}
else {
Discretionary = LocalTaxSubtraction + IDEABDiscretionaryServicesCost + IDEABDiscResCare;
}
IDEABAward = (RelatedServicesCost + ResidentialCare + TotalCostforResPlacement) - Number(Discretionary));
//IDEABAward = (Number(RelatedServicesCost) + Number(ResidentialCare) + Number(TotalCostforResPlacement)) - Number(Discretionary));
document.getElementById('<%= DiscretionaryTotal.ClientID %>').value = Discretionary;
document.getElementById('<%= IdeaBAward.ClientID %>').value = IDEABAward;
}


//]]>
</script>




<td>
<hcf:CurrencyBox ID="LocalTaxShareSubtraction" OnBlur= "updateFiscalGrid();" Precision="2" runat="server" />
</td>

最佳答案

使用浏览器开发工具查看是否可以从控制台手动调用该函数。如果您仍然得到 Function not defined 然后执行以下操作:

  • 检查拼写错误
  • 如果您使用母版页,请确保您没有将脚本页面的引用放在容器标签内(它会被实际页面内容覆盖,这是个人经验,哈哈)
  • 清除缓存并重新加载页面

关于JavaScript 函数未定义错误(但已定义),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42169588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com