These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

If/then statement with last value being a word

saj
Registered: Oct 15 2008
Posts: 52
Answered

Hi. I have an If then statement that I need the last calculation to become a word.
This is (part) of my formula: The last if statement "if (v2 >= 120) f2.value = 0;". I want 0 to say "Request". I think I use the ConvertToWords but, I'm not sure how to do it.
 
var v1 = this.getField("Quantity DropDown_1").value;
var v2 = this.getField("PageCount_1").value;
var f2 = getField("Price2_1");
 
// From 25 to 49
if ( (v1 >= 25 && v1 <= 49) && (v2 == 16) ) f2.value = 13.39;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 20) ) f2.value = 14.52;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 24) ) f2.value = 15.64;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 28) ) f2.value = 16.77;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 32) ) f2.value = 17.89;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 36) ) f2.value = 18.97;
 
if (v2 >= 120) f2.value = 0;
 
thanks for your help.
sara

My Product Information:
Acrobat Pro Extended 9.4.2, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The ConvertToWords function takes a numeric input and returns the numeric value as a string of words.

Do you want all of the values to be spelled out as words and only when the value of "PageCount_1" is zero have the word 'Request' appear?

Or do you want the numeric values displayed and only when the value of "PageCount_1" is zero have the word 'Request' appear?

What value do you want displayed when none of your test are met?

George Kaiser

saj
Registered: Oct 15 2008
Posts: 52
I want the values to remain and only when v2 >=120, do I want f2 value to be listed as "Request."Is that possible?

thanks for your help.
sara

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
Yes it is. You do not need any special functions. You need to set the format for the field "Price2_1" to 'None' so that field can accept a text value.

var v1 = this.getField("Quantity DropDown_1").value;
var v2 = this.getField("PageCount_1").value;
var f2 = getField("Price2_1");

// From 25 to 49
if ( (v1 >= 25 && v1 <= 49) && (v2 == 16) ) f2.value = 13.39;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 20) ) f2.value = 14.52;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 24) ) f2.value = 15.64;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 28) ) f2.value = 16.77;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 32) ) f2.value = 17.89;
if ( (v1 >= 25 && v1 <= 49) && (v2 == 36) ) f2.value = 18.97;
if (v2 >= 120) f2.value = "Request';
..
..
If you need formatted numeric values, then you can use the 'util.printf' method to set the field to the formatted numeric values.

George Kaiser

saj
Registered: Oct 15 2008
Posts: 52
awh...that is easy! I should have thought of that! Thanks for your help. Greatly appreciated.