Skip to main content
JH313
Participant
May 15, 2017 12:44 PM UTC
Answered

How to Change values depending on Number input on Form?

I have a text field on my form labelled "M1" on my pdf.   The value of M1 will always be a number ranging from 1-6.

I have three additional text fields on the form labelled T1, T2 and T3.

I would like the values of T1 T2 & T3 to change, depending on what number I type in M1

For example,

If I type the number "1" in M1, i would like  T1 =1, T2 is left empty, and T3  left empty

If I type in the number "2"     T1= "1-2"      T2=left empty,      and T3 left empty.

If I type in the number "3"    T1= "1-2"       T2=3,                     and T3 left empty.

If I type in the number "4"    T1= "1-2"      T2=3-4,                     and T3 left empty.

If I type in the number "5"    T1= "1-2"      T2=3-4,                     and T3= 5

If I type in the number "6"    T1= "1-2"      T2=3-4,                     and T3= 5-6

Your help would be greatly appreciated!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
May 15, 2017 5:07 PM UTC

I'll provide you with the first step in this code. You can extrapolate the rest from it... As the custom validation script of M1 enter this:

if (event.value=="1") {

     this.getField("T1").value = "1";

     this.getField("T2").value = "";

     this.getField("T3").value = "";

}

4 replies

Inspiring
May 15, 2017 3:34 PM UTC

Both Adobe and Mozilla provide free references for Acrobat JavaScript API Reference and the MDN JavaScript Reference.

Translate
JH313
JH313Author
Participant
May 15, 2017 4:11 PM UTC

I'm sorry, I'm very much novice at writing scripts. I think I just need the actual script.

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 15, 2017 5:07 PM UTC

I'll provide you with the first step in this code. You can extrapolate the rest from it... As the custom validation script of M1 enter this:

if (event.value=="1") {

     this.getField("T1").value = "1";

     this.getField("T2").value = "";

     this.getField("T3").value = "";

}

Translate