How do I go about fetching from (or writing to) input fields relative to $(this) in a form?
I wish to loop through all input fields "antal" and calculate subtotals based on "antal" multiplied by the price relative to "antal" and store the calculated price in a subtotal input field relative to "antal".
A full pen here http://codepen.io/Ktraving/pen/RKRGQG
$("input").change(function(){
var subtot=0;
var total=0;
$("input[name=antal]").each(function(){
subtot = subtot + (parseInt($(this).val()) * $("input[name=pris]").val());
$("input[name=subpris]").val(subtot);
});
/* Totalling the subtotals */
$("input[name=subpris]").each(function(){
total = total + parseInt($(this).val());
});
$("input[name=totpris]").val(total);
});