フォームに8種類のテキストフィールドがありますが、これは顧客請求書の一部です。 は、ここでは、私が合計値としてすべての値の合計を表示したい。このことから複数のテキストボックスから値を取得するJavaScriptのkeypressで
<input type="text" name="txtcustomduty" class="form-control" placeholder="Customs Duty">
<input type="text" name="txtlcltranspotation" class="form-control" placeholder="Local Transportation">
......
up to 8
ある
<span>Total extra cost:1678</span>
どのようにすることができます任意のテキストフィールドの値が変更されたときに変更し、そうしなければなりません私は完全にkeyup
イベントを使用してそれを行うのですか?私は、各テキストフィールドにonkeyupのイベントを添付した
UPDATE
`onkeyup="findSum(this.value)"'
と私は店のためのグローバル配列を使用していた入力はvar extras=[]
function findSum(value)
{
if(value!=''){
console.log(value);
extras.push(parseInt(value));
if(extras!='')
$('#extratotal').text(extras.reduce(getSum));
else $('#extratotal').text('0');
}
}
しかし、そのない値よく働いた
これまでに何を試みましたか? – Dacaspex