Copy link to clipboard
Copied
Hi
I have 15 fields in my form with different amounts and checkboxes.
I need help in such a way like when I check to mark the boxes it only counts the amount of all checked boxes and skips the sum of unchecked boxes.
Please I need your kind help is there any posibility.
Copy link to clipboard
Copied
Hi,
I would add a Document level JavaScript function something like :
( to add a Document level script, search the tools for "Document" and click "Document JavaScripts" then click add
function addToTotal ( number){
addSubtractTotal ( number, true);
}
function subtractFromTotal ( number) {
addSubtractTotal ( number, false);
}
function addSubtractTotal ( number, bAdd){
var totalField = this.getField("TotalField");
if ( bAdd){
totalField.value += number;
} else {
totalField.value -= number;
}
}
then on the mouse up action of each checkbox you can call the correct function depending on whether it is being checked or unchecked.
if (event.target.value == "Yes") {
addToTotal ( 15);
} else {
subtractFromTotal ( 15);
}
NOTE: you will need to alter the names of field in this piece of code : this.getField("TotalField");
AND update the amount you want it to go up by
Copy link to clipboard
Copied
You don't need script for this, set checkbox export value to be price for that item, then in total field go to calculate tab, select 'Value is the' leave it as 'sum+' and 'pick' checkboxes.