• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Adjust height of Button according to value of a field

Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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.

TOPICS
JavaScript , PDF forms

Views

631

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 20, 2021 Jan 20, 2021

Votes

Translate

Translate
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

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 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

I've actually developed a (paid-for) script that does something very similar, only horizontally instead of vertically. You can find it here: https://www.try67.com/tool/acrobat-convert-percentage-fields-to-a-progress-bar

I've also created custom-made tools for my clients that do pretty much what you've described, so if you're interested I'd be happy to create one for you too (for a fee, of course). You can contact me privately via [try6767 at gmail.com] to discuss it further.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

This tool looks great and may indeed do the job - thanks so much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

You can create buttons with different heights and show / hide the buttons. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 19, 2021 Jan 19, 2021

Copy link to clipboard

Copied

ooo - a bit labour intensive (I actually have 5 question sets!!) but I like it as something I might actually be able to figure out and make work! Thanks 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2021 Jan 20, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 21, 2021 Jan 21, 2021

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 21, 2021 Jan 21, 2021

Copy link to clipboard

Copied

LATEST

This is super useful - thank you so much 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines