Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonasEriksson/de71e55690c54285cae494fd817363a0 to your computer and use it in GitHub Desktop.
Save JonasEriksson/de71e55690c54285cae494fd817363a0 to your computer and use it in GitHub Desktop.
<!--- JS - this goes into the html footer --->
<script>
$(document).ready(function() {
function recalculate() {
var sum = 0;
$("input[type=checkbox]:checked").each(function() {
sum += parseInt($(this).attr("optionpricelocalcurrency"));
});
$("##calculatedvalue").html(sum);
}
$("input[type=checkbox]").change(function() {
recalculate();
});
});
</script>
<!--- html example - for the template ---->
<p><input type="checkbox" value="#dbresult.optionpricelocalcurrency#" rel="#dbresult.optionpricelocalcurrency#">#dbresult.optionlisttitle#</p>
<span id="calculatedvalue"></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment