Hi Jan,
You could use a hidden free format variable to store the value from the total field, but I found it easier to just use the numeric fields themselves. The below JavaScript can be used on the same page as the grid question to display the total in real time. Just be sure to replace 'gridquestion' with your question's name and update the 'r1'/'c1' stuff with the relevant rows/columns of your question.
Sum: <div id="gridsum"><span>0</span></div>
<script type="text/javascript">
$(document).ready(function(){
var updateSum = function(){
var column1 = Number($('#gridquestion_r1_c1').val()) || 0;
var column2 = Number($('#gridquestion_r1_c2').val()) || 0;
var column3 = Number($('#gridquestion_r1_c3').val()) || 0;
var column4 = Number($('#gridquestion_r1_c4').val()) || 0;
var sum = column1 + column2 + column3 + column4;
$('#gridsum span').text(sum);
};
$('#gridquestion_r1_c1').keyup(function(){
updateSum();
});
$('#gridquestion_r1_c2').keyup(function(){
updateSum();
});
$('#gridquestion_r1_c3').keyup(function(){
updateSum();
});
$('#gridquestion_r1_c4').keyup(function(){
updateSum();
});
})
</script>
If you're on a different page that comes after the grid question, the total can be easily displayed with code to this effect:
Sum: <div id="gridsum"><span>0</span></div>
<script type="text/javascript">
$(document).ready(function(){
var total = [% gridquestion_r1_c1 + gridquestion_r1_c2 + gridquestion_r1_c3 + gridquestion_r1_c4 %];
$('#gridsum span').text(total);
})
</script>
For the constant sum question, you can set the total value with Sawtooth Script:
[% gridquestion_r1_c1 + gridquestion_r1_c2 + gridquestion_r1_c3 + gridquestion_r1_c4 %]