Example how sum all values of those fields
<input type="hidden" name="hidden[1]" class="sum" value="31">
<input type="hidden" name="hidden[2]" class="sum" value="21">
<input type="hidden" name="hidden[3]" class="sum" value="321">
<input type="hidden" name="hidden[4]" class="sum" value="-31">
<input type="hidden" name="hidden[5]" class="sum" value="31.12">
<input type="hidden" name="hidden[6]" class="sum" value="0">
If you have 'sum' as a class to define all the elements that must be calculated,
below code should work...
<script>
var total = 0;
$('.sum').each(function () {
total += parseFloat(this.value);
});
</script>
<input type="hidden" name="hidden[1]" class="sum" value="31">
<input type="hidden" name="hidden[2]" class="sum" value="21">
<input type="hidden" name="hidden[3]" class="sum" value="321">
<input type="hidden" name="hidden[4]" class="sum" value="-31">
<input type="hidden" name="hidden[5]" class="sum" value="31.12">
<input type="hidden" name="hidden[6]" class="sum" value="0">
If you have 'sum' as a class to define all the elements that must be calculated,
below code should work...
<script>
var total = 0;
$('.sum').each(function () {
total += parseFloat(this.value);
});
</script>
No comments:
Post a Comment