Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改一个文本框值时使用哪个事件?它应该更改jquery中另一个文本框中的相关值_Jquery_Asp.net Mvc_Events_Textbox_Onchange - Fatal编程技术网

更改一个文本框值时使用哪个事件?它应该更改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" />

现在根据代码,当我更改TotalAbourChargetotalFineRate时,相关值应显示$(“#单价包含税”).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);
});