Start by adding this HTML to the label of your price attribute:
<input type="hidden" class="myPriceAttribute"/>
(You can define an internal label to keep this HTML from showing up in analysis.)
Then you can add this to wherever on the page you want to display the total price:
<span class="myTotalPrice"></span>
Finally, including this code in the CBC will do all the work we need:
<script>
$(document).ready(updateTotalPrice);
$('#[% QuestionName() %]_div input').keyup(updateTotalPrice);
function updateTotalPrice() {
var index = $('.myPriceAttribute').closest('.cbc_cell').index();
var total = 0;
$('#[% QuestionName() %]_div .cbc_concept:not(.none_concept)').each(function(){
var price = Number($(this).children().eq(index).text().replace(/[^0-9\.]/g, ''));
var quantity = Number($(this).find('.numeric_input').val());
total += price * quantity;
});
total = total.toFixed(2);
$('.myTotalPrice').text(total);
}
</script>