Skip to content

Commit

Permalink
Onchange
Browse files Browse the repository at this point in the history
  • Loading branch information
igorolhovskisprintit committed Jun 28, 2022
1 parent 947e3d0 commit 0cc6687
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions katelaskenta/scripts.katelaskenta.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ $(document).ready(function () {
var lisaaHintaanKate;
var asetaUusiHinta;

$("[name='hintojen_muutos']").on("change",function() {
if(this.checked) {
$("[name='laskekate']").prop("checked", true);
$(".changepricein").change(function() {
var katesarakechange = $(this).val();
if(katesarakechange > 0) {
var kehahintachange = $(this).parent().parent("[data-kehahinta]").data("kehahinta");
var changepricein_laskettu = lisaaHinnastaKate(kehahintachange, katesarakechange);
if(changepricein_laskettu >= 0) {
$(this).parent().next().find(".disabled").val(changepricein_laskettu);
$(this).css("color", "red");
} else {
alert("Uuden hinnan \""+katesarakechange+"\" laskettu kate ei voi olla negatiivinen!");
}
}
});

Expand Down Expand Up @@ -203,9 +211,7 @@ $(document).ready(function () {
var changepricein_laskettu = lisaaHinnastaKate(kehahintachange, katesarakechange);
if(changepricein_laskettu >= 0) {
$(this).parent().next().find(".disabled").val(changepricein_laskettu);
if($(this).hasClass("colchanged")) {
$(this).css("color", "red");
}
$(this).css("color", "red");
} else {
alert("Uuden hinnan \""+katesarakechange+"\" laskettu kate ei voi olla negatiivinen!");
}
Expand Down

0 comments on commit 0cc6687

Please sign in to comment.