【发布时间】:2017-10-12 18:11:22
【问题描述】:
我只想根据复选框的选择自动填充输入字段。 下面是我正在使用的代码。它工作正常,但问题是我只想在用户选中复选框时填写输入字段。如果用户再次取消选中该复选框,我想删除由选择填充的值。
<script>
$('.dtgPaymentDetails').change(function () {
var flag = false;
var receiptid = $(this).attr("receiptid");
var receiptamount = $(this).attr("receiptamt");
var totalamount = $("#txtTotatAmount").val();
if (isNaN(parseInt(totalamount)))
{
totalamount = 0;
}
totalamount = parseInt(totalamount) + parseInt(receiptamount);
$("#txtTotatAmount").val(totalamount);
$("#txtNetAmount").val(totalamount);
});
</script>
【问题讨论】:
标签: jquery