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

Help with IF and ELSE and then showing it on a TEXT in the Adobe forms

vkvedant
Registered: Dec 6 2008
Posts: 4
Answered

Hi:
I need some help with IF and ELSE and then showing it on a TEXT in the Adobe forms. Can you please help?

What I am trying to do? There is a SummaryValue (a TEXT FIELD) with a number. Based on the value in the SummaryValue, I want a TEXT field to show comments.

If the SummaryValue is between 0 to 0.3 THEN show "Value less than 30"
If the SummaryValue is between 0.3 to 0.38 THEN show "Value betn 31 to 38"
If the SummaryValue is >0.39 THEN show "Value more that 39"

Any help is appreciated.

My Product Information:
Acrobat Standard 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The real code is not that different from your description. You'll need to learn a bit about JavaScript syntax and the Acrobat JavaScript model to fill it out.

For example, to get the value of a form field in an AcroForm, as opposed to a LiveCycle Designer form, use this code.

var nVal = this.getField("SummaryValue").value;

Then to impliment the first "if" statement use this code:

if( (nVal >= 0) && (nVal <= 0.3) )
this.getField("CommentField").value = "Value is less than 30";


The rest of the if/else structure follows a similar pattern. When it comes to programming the details are particularly important. You should have a book on Core JavaScript to help you out in this area (the O'Reilly book is my favorite).

There's gobs of information about JavaScript on the web. But you have to be careful about what you read. There's Core JavaScript, which is just the basic JavaScript language. Then there are the JavaScript models for different applications. Most of the information out there is related to Browser Scripting, not Acrobat. You can find videos and info specifically about Acrobat JavaScript on this site and at www.pdfscripting.com.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

vkvedant
Registered: Dec 6 2008
Posts: 4
Thanks for your help - IT IS EXACTLY what I was looking for. I will browse thru the books.

var Ratio = this.getField("SUMMARYRow4_2").value;
event.value=Ratio;


if ((Ratio >=0) && (Ratio <=30)){
event.value = 'Between 0 to 30';
}else if ((Ratio >30) && (Ratio <=38))
{
event.value = 'BETWEEN 30 and 38';
}else if ((Ratio >38) && (Ratio <=100))
{
event.value = 'MORE THAN 38';
}