Hi,
if you insist on showing the total here, well, with a small javascript snippet
And the script:
Code:
<script type="text/javascript" charset="utf-8">
$(document).on('ready pjax:scriptcomplete',function(){
var thisQuestion = $('#question{QID}');
$('.answer-item.answer_cell_X002', thisQuestion).addClass('quantity');
$('.answer-item.answer_cell_X004', thisQuestion).addClass('amount');
$('.answer-item.answer_cell_X005', thisQuestion).addClass('sum');
$('.sum input[type="text"]', thisQuestion).prop('readonly', true);
$('.quantity', thisQuestion).on('change', function(i) {
if($(this).closest('.answer-item').hasClass('answer_cell_X002')) {
handleSum($(this));
}
});
$('.amount', thisQuestion).on('change', function(i) {
if($(this).closest('.answer-item').hasClass('answer_cell_X004')) {
handleSum($(this));
}
});
function handleSum(thisSelect) {
var thisRow = $(thisSelect).closest('tr.subquestion-list');
var item2 = $('.answer_cell_X002', thisRow);
var item4 = $('.answer_cell_X004', thisRow);
var item5 = $('.answer_cell_X005', thisRow);
var w1=$('input:text', item2).val();
var w2=$('input:text', item4).val();
var w3=(w1*w2).toFixed(2);;
if(w3>0) {
$('input:text', item5).val('R$ ' + w3).trigger('change');
} else {
$('input:text', item5).val('').trigger('change');
}
}
});
</script>
You see, I coded the x-axis "X001", "X002",...
As I am not familiar with javascript I merged parts from yet available scripts here.
Seems to work.
Other - more experienced - may improve
Joffm
BTW: I know that it should be "amount"