我使用了 MVC4,我想在使用的 Javascript 模型的属性中设置值
我试过这段代码
function updateTotals() {
debugger;
var academicAchievement = $('#AcademicAchievement').val();
var academicGrowth = $('#AcademicGrowth').val();
var academicGrowthGaps = $('#AcademicGrowthGaps').val();
var postsecondarAndWorkforceReadiness = $('#PostsecondarAndWorkforceReadiness').val();
if ("@Model.complianceTypeId" != 11 && academicAchievement != "" && academicAchievement != undefined && academicGrowth != "" && academicGrowth != undefined && academicGrowthGaps != "" && academicGrowthGaps != undefined) {
$('#Total').val("");
$('#Total').val(((parseInt(academicAchievement, 10) + parseInt(academicGrowth, 10) + parseInt(academicGrowthGaps, 10)) / 100) * 100 + "%");
$('#Total').attr("disabled", "disabled");
$('#TotalValuehdn').val((((parseInt(postsecondarAndWorkforceReadiness, 10) + parseInt(academicAchievement, 10) + parseInt(academicGrowth, 10) + parseInt(academicGrowthGaps, 10)) / 100) * 100 + "%"));
}
if ("@Model.complianceTypeId" == 11 && postsecondarAndWorkforceReadiness != "" && postsecondarAndWorkforceReadiness != undefined && academicAchievement != "" && academicAchievement != undefined && academicGrowth != "" && academicGrowth != undefined && academicGrowthGaps != "" && academicGrowthGaps != undefined) {
$('#Total').val("");
$('#Total').val((((parseInt(postsecondarAndWorkforceReadiness, 10) + parseInt(academicAchievement, 10) + parseInt(academicGrowth, 10) + parseInt(academicGrowthGaps, 10)) / 100) * 100 + "%"));
$('#Total').attr("disabled", "disabled");
**"@Model.complianceTypeId"**= (((parseInt(postsecondarAndWorkforceReadiness, 10) + parseInt(academicAchievement, 10) + parseInt(academicGrowth, 10) + parseInt(academicGrowthGaps, 10)) / 100) * 100 + "%");
}
}
但是这一行 “@Model.complianceTypeId”抛出了这个错误L- value is expected
我有错误图像。但我只有 7 点。所以我不能添加那个图像。所以我稍后会放那个图像