私は予算計算機を作成していて、ユーザーが自分の経費の表を作成できるようにしたいところです。
最初にテーブルに設定されているのは、家賃、水道、電気/ガスの3つです。最後の行がボタンになった後、クリックして現在の最後の行の後に新しい行を追加できます。
これが私の問題です。ユーザーは、私が提供する3つの列(隔週、月次、または年次)のいずれかに費用を入力できるようにします。これは、ユーザーがその特定の費用を知っているのは、これらの期間の1つだけであるためです。それらの計算を、自動的に、他のセルに対して実行します。
これにどうアプローチするかわかりません。COLUMNの特定の方程式を定義して、その列に入力された値がそれに応じて他の列を更新し、どちらが問題にならないようにすることができるExcelスプレッドシートを模倣するプラグインまたはライブラリが利用可能ですか(隔週、毎月、毎年)彼らは使用しましたか?
これが私のコードの現在のスナップショットのこのフィドルからのいくつかの関連するコードです:
<table class="moneyTable width100" id="expenses">
<tr>
<td class="deleteCell fill-white"></td>
<td class="right-border fill-white width50">
<h3>Expense Type</h3>
</td>
<td class="fill-white">
<h3>Bi-Weekly</h3>
</td>
<td class="fill-white">
<h3>Monthly</h3>
</td>
<td class="fill-white">
<h3>Annually</h3>
</td>
</tr>
<tr>
<td class="deleteCell">
<h4 class="delete"><a class="deleteRow">[x]</a></h4>
</td>
<td class="right-border"><input class="expense"
type="text" value="Rent" width="50"></td>
<td><input class="expense currency" disabled="disabled"
placeholder="0" type="text" width="50"></td>
<td><input class="expense currency" disabled="disabled" placeholder="0" type="text" width="50"></td>
<td><input class="expense currency" disabled="disabled" placeholder="0" type="text" width="50"></td>
</tr>
<tr>
<td class="deleteCell">
<h4 class="delete"><a class="deleteRow">[x]</a></h4>
</td>
<td class="right-border"><input class="expense" id="titleWater"
type="text" value="Water" width="50"></td>
<td><input class="expense currency" placeholder="0"
type="text" width="50"></td>
<td><input class="expense currency" placeholder="0"
type="text" width="50"></td>
<td><input class="expense currency" placeholder="0"
type="text" width="50"></td>
</tr>
<tr>
<td class="deleteCell">
<h4 class="delete"><a class="deleteRow">[x]</a></h4>
</td>
<td class="right-border"><input class="expense" id="titleElectric"
type="text" value="Electric/Gas" width="50"></td>
<td><input class="expense currency" placeholder="0"
type="text" width="50"></td>
<td><input class="expense currency" placeholder=
"0" type="text" width="50"></td>
<td><input class="expense currency" placeholder=
"0" type="text" width="50"></td>
</tr>
<tr>
<td class="deleteCell"></td>
<td class="right-border">
<h3><a class="addRow">(Add Row)</a></h3>
</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td class="deleteCell fill-white"></td>
<td class="right-border fill-white">
<h3>Total Expenses</h3>
</td>
<td class="fill-white">
<h4 id="bwNet"></h4>
</td>
<td class="fill-white">
<h4 id="monNet"></h4>
</td>
<td class="fill-white">
<h4 id="annNet"></h4>
</td>
</tr>
$(document).ready(function() {
$('#expenses input:gt(0)').keyup(function() {
$(this).closest('td').siblings('td').not(':first').find('input').not(this).val($(this).val());
});
});
$(document).ready(function () {
$("a.deleteRow").live('click', function (){
$(this).parent().parent().insertBefore();
});
$("a.addRow").live('click', function (){
$("table.moneyTable tr:last").prev('tr').before("<tr class='bottom-border'><td class='deleteCell'><a class='deleteRow'><h4 class='delete'>[x]</h4></a></td><td class='right-border label'><input class='expense' type='text' width='50' placeholder='(...)' /></td><td><input class='expense currency' type='text' width='50' placeholder='0' /></td><td><input class='expense currency' type='text' width='50' placeholder='0' /></td><td><input class='expense currency' type='text' width='50' placeholder='0' /></td></tr>");
});
});