Skip to main content
frankimartelly
Participating Frequently
January 19, 2021
Answered

Adjust height of Button according to value of a field

  • January 19, 2021
  • 5 replies
  • 1495 views

First of all I'm very new to javascript and don't really know what I'm doing so apologies in advance. I want to set a button in an Acrobat form to adjust it's height according to the value it takes from another field. Is this possible? Thanks.

This topic has been closed for replies.
Correct answer JR Boulay

You should examine how this example works:

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:d72fc67d-9788-40f4-b939-ee9638d3503a

 

(edited)

5 replies

JR Boulay
Community Expert
Community Expert
January 21, 2021
Acrobate du PDF, InDesigner et Photoshopographe
frankimartelly
Participating Frequently
January 21, 2021

This is super useful - thank you so much 🙂

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
January 20, 2021
Acrobate du PDF, InDesigner et Photoshopographe
frankimartelly
Participating Frequently
January 20, 2021

Thanks although the link says the files have been moved or I don't have access?

frankimartelly
Participating Frequently
January 19, 2021

Thanks so much guys. So I have three text fields which I have set to calcuate how many radio buttons are checked for Choice 1, Choice 2 and Choice 3 in a set of questions. The values returned can be between 0 and 20 (ie the question set has 20 questions). I then have three other fields which I've made into buttons, even though they won't do anything, purely so they don't have any actual text content etc. I want to click another 'calculate' button which will gather the three text field values and tell the three buttons to set themselves to those heights in millimetres. So if the text values returned were 5 for Choice 1 (text1), 10 for Choice 2 (text2) and 5 for Choice 3 (text3) the three buttons would change to 5mm high, 10mm high and 5mm high respectively. Hope this makes sense! Thanks again.

try67
Community Expert
Community Expert
January 19, 2021

I see. You want to create a kind of bar chart. This is possible, but not so simple.

You would need to hard-code into the script the default position of the field and then calculate its new rect based on the value, but expressed in PostScript Points instead of millimeters. I would recommend reading the documentation of the rect property of the Field object to see how this can be done.

frankimartelly
Participating Frequently
January 19, 2021

Yes I guess a bar chart is the kind of thing I'm after - a visual representation of a tally of what's been selected,  but maybe this is beyond me. I'll have a read up on the rect property of the Field Object as you recommend. Thanks very much for your help 🙂

try67
Community Expert
Community Expert
January 19, 2021

Yes, it is. You can use the field's Validation or Calculation events to change the size of the button by setting its rect property. You'll need to provide a more clear description of the relation between the value and the height of the button field for additional help with the code.

Bernd Alheit
Community Expert
Community Expert
January 19, 2021

What units does you use? Inches, m, or ...?