Live calculation on page based on checkboxes

I have a page consisting of 2 tables. The table layouts are similar (table 1 has 4 rows; 4 columns ; table 2 has 6 rows; 4 columns ). Column 1 & 2: contain text, column 3 is a price that I am bringing into the table from another question using for example

 $[% FormatNumber(LoaderOpt_price1, ",", ".", 0) %] 
, the last column contain the check boxes.

Respondents are asked to select any item (s).

The client would like to show the respondents the amount of money live on the page, based on their selected answer(s).

So, if I have a based amount of 23678 and I choose checkbox 1 then the price corresponding with that checkbox 1 should be added to the base price and displayed.

I found a previous post with the code


<script>
$(document).ready(function(){
updateDynamicPrice();
$('select').change(updateDynamicPrice);
})

function updateDynamicPrice() {
var base = [% SelectQ0 %];
var select1 = SSI_GetValue('SelectQ1');
var select2 = SSI_GetValue('SelectQ2');
var select3 = SSI_GetValue('SelectQ3');
var select4 = SSI_GetValue('SelectQ4');

var price = base * 5 + 5;
price += select1 ? (select1 - 1) * 4 : 0;
price += select2 ? select2 - 1 : 0;
price += select3;
price += select4 ? select4 - 1 : 0;

$('.dynamicPrice').text(price);
}
</script>


I don't know how to modify the code to work with checkboxes.

Thank you in advance for any help you can provide.

Resolved
4 replies