我正在开发 MVC 应用程序。在视图中,我声明了一些变量,我想在 Jscript 中使用它。
@model PaymentAdviceEntity.EMI
@{
ViewBag.Title = "Create";
double TotalAmt = 0;
}
@using (Html.BeginForm("Edit", "EMI", FormMethod.Post, new { @id = "frmEdit" }))
{
@if (Model.EMI_Child.Count > 0)
{
@foreach (var PaidEMIList in Model.EMI_Child)
{
TotalAmt = TotalAmt + PaidEMIList.Amount;
}
}
}
<script>
$(document).ready(function () {
CheckBalAmt();
});
function CheckBalAmt()
{
var nTotalAmount = document.getElementById("TotalAmount").value;
var nAllreadyPaidAmount = document.getElementById("AllreadyPaidAmount").value;
var BalAmt = nTotalAmount - nAllreadyPaidAmount;
var totalAmt1 = @TotalAmt; <- Shows error here...
var BalAndTotalAmt = BalAmt +totalAmt1;
$('.BalanceAmt').text("Bal Amt. : " + BalAndTotalAmt );
}
</script>
在上面的 CheckBalAmt() 方法中,我想显示变量 TotalAmt 的值......但它没有显示任何东西......