Expand my Community achievements bar.

SOLVED

how to set the max height of an image field

Avatar

Level 3

I have a repeatable image field in my form where users can add images, and I have created two buttons below the image field that allow the user to resize it. The script on the buttons is:

ImageField1.h = (xfa.layout.h(ImageField1, "points")*1.1 + "points").toString();

ImageField1.hAlign = "center";

Size_buttons.hAlign = "center";

&

ImageField1.h = (xfa.layout.h(ImageField1, "points")/1.1 + "points").toString();

ImageField1.hAlign = "center";

Size_buttons.hAlign = "center";

My problem is that I want to specify a maximum height that the image can be so that it does not flow off of the page (this is a problem because the buttons for resizing the image are beneath it and will be inaccessible if the user makes the images too large). I have tried to place the following script in the image field, but it does not help.

this.resolveNode("ImageField1").maxH = "8.5in";

Any suggestions?

1 Accepted Solution

Avatar

Correct answer by
Level 8

Use conditional statement in your script to prevent the code from executing.

Using your code:

if (xfa.layout.h(ImageField1,"in") < 8.5){

     ImageField1.h = (xfa.layout.h(ImageField1, "points")*1.1 + "points").toString();

     ImageField1.hAlign = "center";

     Size_buttons.hAlign = "center";

}

Kyle

View solution in original post

1 Reply

Avatar

Correct answer by
Level 8

Use conditional statement in your script to prevent the code from executing.

Using your code:

if (xfa.layout.h(ImageField1,"in") < 8.5){

     ImageField1.h = (xfa.layout.h(ImageField1, "points")*1.1 + "points").toString();

     ImageField1.hAlign = "center";

     Size_buttons.hAlign = "center";

}

Kyle