I have created a form in Adobe Acrobat Pro 9 where I have assigned values to checkboxes. I have managed to sum the total of the checkboxes, which is displayed ina separate textbox, but now I need to calculate the percentage of that against the total. CAn anyone help?

Dani AI

Generated

Nice work by — retrieving the summed checkbox total and dividing by the total possible points is the right approach. A few small refinements make the result more reliable and easier to display: coerce field values to numbers, guard against divide‑by‑zero, keep the percent as a numeric value (so Acrobat can format it), and ensure the sum field is calculated before the percent field.

// Place in the percentage field's Custom Calculation script.
// Replace "SumField" and "MaxPoints" with the actual field names.
var sum = Number(this.getField("SumField").value) || 0;
var max = Number(this.getField("MaxPoints").value) || 0;

if (max <= 0) {
  // leave blank (or use "0" to show 0% when the Format tab is set to Percent)
  event.value = "";
} else {
  // assign the numeric fraction; set the field's Format tab to "Percent"
  event.value = sum / max;

  // If a text percent is preferred instead, use:
  // event.value = ((sum / max) * 100).toFixed(1) + "%";
}

Troubleshooting notes: ensure checkbox export values are numeric (for example "1" or "5" rather than "Yes"), confirm the sum field is a numeric calculation (not a string), and check Acrobat's calculate order so the sum computes before the percent. Prefer using the field Format tab set to Percent and choosing decimal places — this keeps the value numeric (useful for further math) and avoids string concatenation issues when appending a '%' in script.

Worked it out if anyone else needs:
var TPA = +this.getField("Total Points awarded").value;
event.value = (TPA/45);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.