Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I let my pdf print a certain word depending on field input? 1

Status
Not open for further replies.

Laurens1

Technical User
Nov 3, 2010
2
NL
Dear All,

I am building a pdf form with a few pairs of radio buttons. Depending on whether people click "yes" of "no" a value of either 0 or 1 is added to a total score. This total score will appear in score field of the bottom of the document. So far, I am not experiencing any problems. What I would like to do know is the following:

If people score between 0 and 5 I'd like the word "LOW" to appear in a field. When people score between 6 and 14, the word "MEDIUM" should appear and for scores ranging between 15 and 37, the word "HIGH" should be printed. What code should I add to a field to get this done?

Please help me out here!

Thanks a million!

Laurens
 
Laurens,

If using livecycle designer, you should be able to do something as a calc event using FormCalc:

var total = sum (Table1.Row2.Sum + Table1.Row10.Sum)

if (total <= 0) then
"Low"
elseif (total <= 14) then
"Medium"
elseif (total <=37) then
"High"
endif

____
The Table1.Row2.Sum can also be the Binding assigned to the cells you're adding if you're not using a table. Also, make sure the cell where you're entering this formula is a text field.
 
Thanks for your advice! I tried to use it, but for some reason, I cannot get in to work (I am quite a newbie). I attached a simplified version of the form I am building in Acrobat. Could you have a look at it and see how I can get the "Bottom Field" to print certain words depending on a score.
 
 http://www.mediafire.com/file/8p7257x037bc092/Sample%20Form.pdf
In livecycle, click on the bottom field 'area'. Now do the following:

1.) Click on Window in your file/edit bar.
2.) Click Script Editor
3.) Next to show, select "Calculate"
4.) Next to Language, select "FormCalc"
5.) Next to Run At, select "Client"

Now enter the code below:
var rb1
var rb2
var rb3
var rb4
var rb5

if (button1.rawValue==1) then
rb1 = "1"
endif
if (button2.rawValue==1) then
rb2 = "1"
endif
if (button3.rawValue==1) then
rb3 = "1"
endif
if (button4.rawValue==1) then
rb4 = "1"
endif
if (button5.rawValue==1) then
rb5 = "1"
endif
var total = sum (rb1 + rb2 + rb3 + rb4 + rb5)

if (total <= 2) then
"Low"
elseif (total <= 4) then
"Medium"
elseif (total <=5) then
"High"
endif

Rename your radio button groups into "button1" - "button5" and presto chango! Let me know if you have additional questions.

PS
There may be an easier way to do this as I have a tendency to over complicate things from time to time, but this appears to work well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top