Fix automatically syncing amounts when editing simple transaction

This commit is contained in:
RunasSudo 2024-04-06 18:55:27 +11:00
parent ca7cbf6481
commit 9f72404aed
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 4 additions and 9 deletions

View File

@ -97,7 +97,7 @@
{{ 'Edit' if transaction and transaction.id else 'New' }} transaction
</h1>
<form method="POST">
<form method="POST" id="edit-transaction-form">
<table class="min-w-full">
<thead>
<tr class="border-b border-gray-300">
@ -220,19 +220,14 @@
}
function changeAmount(el) {
let amountInputs = document.querySelectorAll('input[name="amount"]');
let amountInputs = document.querySelectorAll('#edit-transaction-form input[name="amount"]');
if (amountInputs.length === 2) {
// Get other input
let otherInput;
for (inp of amountInputs) {
if (inp !== el) {
otherInput = inp;
break;
// Update other input with amount
inp.value = el.value;
}
}
// Update other input with amount
otherInput.value = el.value;
}
}
</script>