## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

• Multiple Check Box Script

# Multiple Check Box Script

New Here ,
May 25, 2021 May 25, 2021

Copied

Hi all. I'm trying to write a script that calculates values based on which check boxes are selected. Let's say my check boxes are named checkbox1, checkbox2, checkbox3, and checkbox4. If checkbox1 and checkbox2 are both selected, I need to divide field1 by field2. If checkbox3 and checkbox4 are selected, I need to divide field3 by field4. Any other combination of checks I want to result in 0.

I'm very new to this so any help would be greatly appreciated.

TOPICS
JavaScript

Views

170

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 25, 2021 May 25, 2021

Copied

LATEST

Try this as custom calculation script:

var c1 = this.getField("checkbox1").valueAsString;
var c2 = this.getField("checkbox2").valueAsString;
var c3 = this.getField("checkbox3").valueAsString;
var c4 = this.getField("checkbox4").valueAsString;
var f1 = Number(this.getField("field1").value);
var f2 = Number(this.getField("field2").value);
var f3 = Number(this.getField("field3").value);
var f4 = Number(this.getField("field4").value);

if((c1 != "Off" && c2 != "Off" && f1 != "" && f2 != "") && (c3 == "Off" && c4 == "Off"))
event.value = f1/f2;
else if((c3 != "Off" && c4 != "Off" && f3 != "" && f4 != "") && (c1 == "Off" && c2 == "Off"))
event.value = f3/f4;
else event.value = 0;

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources