Skip to content

Commit 379c95b

Browse files
calc error
1 parent 3b08c82 commit 379c95b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

assets/js/product-filter.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ $(document).ready(function() {
111111

112112
$.fn.calculateChange = function() {
113113
var change =
114-
$(this).priceToInt($("#payment").val()) -
115-
$(this).priceToInt($("#payablePrice").val())
114+
$(this).priceToInt($("#payment").val()) -
115+
$(this).priceToInt($("#payablePrice").val());
116116
if (change > 0) {
117117
$("#change").text($(this).formatPrice(change));
118118
} else {
@@ -124,4 +124,17 @@ $(document).ready(function() {
124124
$("#confirmPayment").hide();
125125
}
126126
};
127+
128+
$.fn.delDigits = function() {
129+
$("#payment").val(
130+
$(this).formatPrice(
131+
$(this).priceToInt(
132+
$("#payment")
133+
.val()
134+
.substr(0, $("#payment").val().length - 1),
135+
),
136+
),
137+
);
138+
$(this).calculateChange();
139+
};
127140
});

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ <h4 class="modal-title" id="myLargeModalLabel">Trả tiền</h4>
456456
<br>
457457
<div class="row">
458458
<div class="col-md-3">
459-
<button onclick="$('#payment').val($('#payment').val().substr(0,$('#payment').val().length -1));$(this).calculateChange();" class="btn btn-success btn-lg btn-block"></button>
459+
<button onclick="$(this).delDigits();" class="btn btn-success btn-lg btn-block"></button>
460460
</div>
461461
<div class="col-md-3">
462462
<button onclick="$(this).go(0,false);" class="btn btn-success btn-lg btn-block">0</button>

0 commit comments

Comments
 (0)