更改一个文本框值时使用哪个事件?它应该更改jquery中另一个文本框中的相关值
我想更改多个文本框值,此时结果应该出现在点上的结果文本框值 我在谷歌上搜索了这个问题,大多数人的回答是,从改变事件中,这将起作用,但我尝试改变,以及事件中的仍然对我不起作用 这是我的查看代码更改一个文本框值时使用哪个事件?它应该更改jquery中另一个文本框中的相关值,jquery,asp.net-mvc,events,textbox,onchange,Jquery,Asp.net Mvc,Events,Textbox,Onchange,我想更改多个文本框值,此时结果应该出现在点上的结果文本框值 我在谷歌上搜索了这个问题,大多数人的回答是,从改变事件中,这将起作用,但我尝试改变,以及事件中的仍然对我不起作用 这是我的查看代码 <nop-editor asp-for="Weight" /> <nop-editor asp-for="Quantity" /> <nop-editor asp-for="Fine" /> <nop-ed
<nop-editor asp-for="Weight" />
<nop-editor asp-for="Quantity" />
<nop-editor asp-for="Fine" />
<nop-editor asp-for="Rate" />
<nop-editor asp-for="LabourCharge" />
<nop-editor asp-for="UnitPriceInclTax" />
现在根据代码,当我更改TotalAbourCharge或totalFineRate时,相关值应显示$(“#单价包含税”).val()哪个不起作用。您能在问题中显示实际的HTML吗?这样我们就可以创建一个工作示例来调试这里的
selectedLabourChargeUnitId
?还有,为什么不直接使用输入
作为选择器呢?
$("#LabourCharge, #LabourChargeUnit, #Rate").on('input', function () {
var fine = $('input[id="Fine"]').val();
var rate = $('input[id="Rate"]').val();
totalFineRate = fine * rate;
if (selectedLabourChargeUnitId == 1) {
var weight = $('input[id="Weight"]').val();
var labourCharge = $('input[id="LabourCharge"]').val();
var totalLabourCharge = weight * labourCharge;
}
if (selectedLabourChargeUnitId == 2) {
var pcs = $('input[id="Quantity"]').val();
var labourCharge = $('input[id="LabourCharge"]').val();
var totalLabourCharge = pcs * labourCharge;
}
totalPrice = totalLabourCharge + totalFineRate;
$('#UnitPriceInclTax').val(totalPrice);
});