Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Insert numbers depending on which checkboxes are checked

New Here ,
Apr 09, 2025 Apr 09, 2025

This one has me stumped.  I have four checkboxes named A, B, C and D.  I also have a text field that is formatted for numbers.  Two of the four check boxes will alway be checked.  If I check the A checkbox and C checkbox OR the A checkbox and the D checkbox, I want the number 0 to appear in the Numbers text field.  If I check the B checkbox and the C checkbox, I want the number 500 to appear in the Numbers text field.  If I check the B checkbox and the D checkbox, I want the number 800 to appear in the Numbers text field.  Thanks for any help with this.

TOPICS
PDF , PDF forms
123
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Apr 09, 2025 Apr 09, 2025

You didn't specify what should happen if C and D are ticked... But at any rate, you can use this code for that:

 

var a = this.getField("A").valueAsString!="Off";
var b = this.getField("B").valueAsString!="Off";
var c = this.getField("C").valueAsString!="Off";
var d = this.getField("D").valueAsString!="Off";

if ((a && c) || (a && d)) event.value = 0;
else if (b && c) event.value = 500;
else if (b && d) event.value = 800;
else event.value = "";

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 09, 2025 Apr 09, 2025

You didn't specify what should happen if C and D are ticked... But at any rate, you can use this code for that:

 

var a = this.getField("A").valueAsString!="Off";
var b = this.getField("B").valueAsString!="Off";
var c = this.getField("C").valueAsString!="Off";
var d = this.getField("D").valueAsString!="Off";

if ((a && c) || (a && d)) event.value = 0;
else if (b && c) event.value = 500;
else if (b && d) event.value = 800;
else event.value = "";
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2025 Apr 09, 2025

C and D would never both be ticked.  I'll give this a try and report back.  Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2025 Apr 09, 2025
LATEST

Works perfectly.  Thanks!

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