3 Replies Latest reply on Jun 21, 2014 6:51 PM by MichaelN

Combo box with multiple variables pre populating multiple fields and max value validation script help

I am creating a pdf form that will be used as a calculator, and my javascript knowledge is pretty rudimentary. I can do the simple things, some of what I need to do is over my head.

1. I believe I need to use a combo box to pre populate certain fields. I have 13 variables in the dropdown to choose from, and whatever the client chooses will pre populate three other fields (and each of the 13 variables will populate those three fields differently). I'm not exactly sure how to go about doing this. Is it custom keystroke script or does it require a document script? Also, I'm guessing that whatever script will be a series of if/then statements, correct?

2. Once all the fields have been populated (be it pre population or filled in by the customer), I need to calculate the answer which is not my main problem—I already have the proper calculations in place and they work. The problem is that the answer has a maximum value even if the actual value goes over that max number. So, the actual answer is 14 but the max value can only be 12. How do I get the calculation to replace that actual number (14) with the max number (12)? Is that in the validation tab or should that go elsewhere?

I feel like I know just enough to be dangerous but not terribly effective. Any help is appreciated.

Thanks!

• 1. Re: Combo box with multiple variables pre populating multiple fields and max value validation script help

1. There is a tutorial on this here:

http://acrobatusers.com/tutorials/change_another_field

2. To set the maximum value to 12, try this as the custom calculation script for the field:

//Custom calculation script
//Get value of text field
var a = this.getField("Text1").value;

//If it is > 12, then make it 12
if (a > 12){
a=12
}
event.value = a

You need to replace "Text1" with the name of the field in your form.

• 2. Re: Combo box with multiple variables pre populating multiple fields and max value validation script help

Thank you for your response. I appreciate the guidance.

(I had another issue, but found the problem in the lines prior and fixed it. That part is now working the way it should.)

For your other piece of code limiting the value, I have one question. Do I put that code after the simple calculation I need to get the value? So in this case the formula that gets the actual value is:  (Field1/Field2)*12

Would the code you shared with me need to be a validation script or part of the calculation?

Sorry for more questions. I feel like I almost have it, but not quite. Thanks again for the assistance.

• 3. Re: Combo box with multiple variables pre populating multiple fields and max value validation script help

Yes, it will be part of the calculation script, placed after you calculate the actual value.