Skip to main content
Known Participant
August 19, 2020
Answered

checkbox or radio conditioned upon value in another field

  • August 19, 2020
  • 1 reply
  • 1979 views

Hello, I am a beginner. I have a value that is a weight in "kg" to be entered on the PDF form I want a checkbox or a radio button to be ticked automatically depending on 3 ranges of the weight entered:

  • <1kg
  • 1-3kg 
  • >3kg
I would appreciate it if you could help me to script that, and where to enter this script? Thanks
(if the weight entered in the form is 2.5kg for example, only the second radio button should appear automatically)
Thanks
This topic has been closed for replies.
Correct answer try67

it should be empty


You can use this, then:

 

if (this.getField("CB1").valueAsString=="Off") event.value = "";
else {
var v = Number(this.getField("A").valueAsString) * Number(this.getField("B").valueAsString);
event.value = Math.min(3, v);
}

1 reply

try67
Community Expert
Community Expert
August 19, 2020

What's the name of the radio-button fields, and what are their export values?

Known Participant
August 19, 2020

the names of the radio buttons are

rb1

rb2

rb3

the corresponding values:

1.5 mL

3.25 mL

5 mL

try67
Community Expert
Community Expert
August 19, 2020

What about if the "kg" field is empty?