Copy link to clipboard
Copied
So here's the deal I need to write a javascript that displays a number in a text box based on which checkbox is checked so basically:
Text box 1 must display a number from one of the following lines depending on which Checkbox is Checked
The numbers are for reference only and would be whatever the user entered in that field.
(Checkbox 1) 16
(Checkbox 2) 21
(Checkbox 3) 3
(Checkbox 4) 7
If there is a video or something that can be referenced I'm super new to this and appreciate the education
Copy link to clipboard
Copied
Do you mean that there's a text field next to each check-box, and if that box is ticked the value of the text field should appear in another text field? What if more than one box is ticked? What are the names of the fields involved?
Copy link to clipboard
Copied
try67​
Do you mean that there's a text field next to each check-box: Yes
if that box is ticked the value of the text field should appear in another text field: Yes
What if more than one box is ticked? It would be additive
What are the names of the fields involved?
The Worn fields are named Worn.1, Worn.2 and so on. The Fields AT1.0 to AT1.7 are not relevant (just for notes) AV1.0 to AV1.7 are the fields i want to associate with the check boxes. Sort of "IF Worn.1 is checked then add AV1.0 to AC"
AC is the text box (not in the picture) where the totals would populate. AV fields are numbers only. Thanks for your reply and i really value your assistance
Copy link to clipboard
Copied
OK. Use this code as the custom calculation script of the total field:
var total = 0;
for (var i=0; i<=7; i++) {
if (this.getField("Worn."+i).valueAsString!="Off")
total+=Number(this.getField("AV1."+i).valueAsString);
}
event.value = total;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now