Se om det her giver lidt inspiration:
<!DOCTYPE html>
<html xmlns="
http://www.w3.org/1999/xhtml"><head>
<title>Demo</title>
<script type="text/javascript" src="
http://code.jquery.com/jquery-latest.pack.js"></script> <script type="text/javascript">
$(document).ready(function () {
$('.count, .price, #discount, #freight').blur(function () {
recalc();
});
function recalc() {
var sub1 = 0;
$('.line').each(function (ix, rw) {
var count = $('.count', rw).val();
var price = $('.price', rw).val();
var itemTotal = count * price;
$('.total', rw).val(itemTotal);
sub1 += itemTotal;
});
var discount = $('#discount').val() * 1;
var freight = $('#freight').val() * 1;
var sub2 = sub1 - discount;
var tax = sub2 * 25 / 100;
var sub3 = sub2 + tax;
var total = sub3 + freight;
$('#sub1').val(sub1);
$('#sub2').val(sub2);
$('#tax').val(tax);
$('#sub3').val(sub3);
$('#total').val(total);
}
});
</script>
<style type="text/css">
.row
{
clear: both;
padding: 3px;
}
.item
{
width: 300px;
}
.itemcount
{
width: 100px;
}
.itemprice
{
width: 100px;
}
.itemtotal
{
width: 100px;
}
.inline
{
display: inline;
float: left;
margin: 0;
padding: 0;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="row">
<div class="item inline">
Vare</div>
<div class="itemcount inline">
Antal</div>
<div class="itemprice inline">
á</div>
<div class="itemtotal inline">
Pris</div>
</div>
<div class="row line">
<input type="text" class="item" />
<input type="text" class="itemcount count" />
<input type="text" class="itemprice price" />
<input type="text" class="itemtotal total" />
</div>
<div class="row line">
<input type="text" class="item" />
<input type="text" class="itemcount count" />
<input type="text" class="itemprice price" />
<input type="text" class="itemtotal total" />
</div>
<div class="row line">
<input type="text" class="item" />
<input type="text" class="itemcount count" />
<input type="text" class="itemprice price" />
<input type="text" class="itemtotal total" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Sub 1</div>
<input type="text" id="sub1" class="itemtotal" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Rabat</div>
<input type="text" id="discount" class="itemtotal" value="0"/>
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Sub 2</div>
<input type="text" id="sub2" class="itemtotal" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Moms</div>
<input type="text" id="tax" class="itemtotal" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Sub 3</div>
<input type="text" id="sub3" class="itemtotal" value="0" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Forsendelse</div>
<input type="text" id="freight" class="itemtotal" value="0" />
</div>
<div class="row">
<div class="item inline">
</div>
<div class="itemcount inline">
</div>
<div class="itemprice inline">
Total</div>
<input type="text" id="total" class="itemtotal" />
</div>
</body>
</html>