我有一個JavaScript函數會引起模糊。奇怪的是,我第一次運行它時運行良好,從那以後,我收到一個錯誤,說JavaScript函數沒有定義 - 並停止運行。我搜索了類似的問題,但沒有任何建議能夠解決這個問題。 Asp.Net 3.5 Webforms,如果它很重要。我已經包含了一些可能與問題無關的額外功能和代碼行。我遇到的問題是大功能updateFiscalGrid。綁定到事件的HTML在函數下面。JavaScript函數沒有定義錯誤(但它是定義的)
<%@ 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>
嗨!你檢查過你的代碼嗎?我的意思是在瀏覽器。也許在你的javascript函數'<%%>'裏面設置了一些變量會導致腳本出錯,使得函數'not defined' – MarceloBarbosa
我解決了這個問題!這是一個額外的) –