gpt4 book ai didi

jquery - L 值是预期的 javascript

转载 作者:行者123 更新时间:2023-12-01 00:18:38 25 4
gpt4 key购买 nike

我使用了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-值是预期的

我有错误图像。但我只有 7 点。所以我无法添加该图像。所以我稍后会放置该图像

最佳答案

您无法通过 javascript 设置 Model 对象的属性,原因很简单,您的 Model 位于服务器上,而 javascript 则在客户端上执行。让 javascript 修改某些服务器端值的唯一方法是向服务器发送请求。有很多方法可以做到这一点,其中之一涉及使用 AJAX。

关于jquery - L 值是预期的 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17189686/

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