Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

I'm trying to change font.size with JavaScript on initialize

andreje26334271
Level 1
Level 1

The code below isn't working what coult be wrong?

i have set up the font size for the text field on "0pt" then when opening pdf i check if value is shorter then 50 letters and if so then i have to change the font.size to "10pt".

if (this.rawValue.length <=50) then this.font.size="10pt";

The code doesn't work the font.size stays on value "0pt". Please help.

3 Replies
jasotastic81
Level 7
Level 7

Are you using FormCalc or JavaScript? FormCalc requires the "then" keyword, but doesn't recognize the .length property of rawValue. JavaScript can see the "length" property of your field's rawValue, but it doesn't understand "then."

For JavaScript:


if (this.rawValue.length < 50) this.font.size = "10pt";



For FormCalc:


if (Len(this.rawValue) < 50) then this.font.size = "10pt" endif



andreje26334271
Level 1
Level 1

Hy tnx for answer.

I'm using JavaScript, i wrote as you say but it still doesn't work.

pdf.jpg

jasotastic81
Level 7
Level 7

When I did it, I had a default value set that comes in when the field is initialized, and it works. If your field gets its value from a different source, then it should not be present as it is initialized. I would look into changing the event that this happens with. Layout:ready might be a better place for this.