Skip to main content
paulo55628202
Participant
August 16, 2019
Answered

I use the following script to dynamically make a button add a text field.

  • August 16, 2019
  • 2 replies
  • 981 views

var f = this.addField("myfield","text",0,[0,792,126,770]);

    f.borderColor = color.black;

    f.textSize=12;

    f.textColor=color.black;

It works fine but positions the text field in the top corner of the page, whereas with LiveCycle it was simple to make a new field below an existing one, then another each time the button was clicked. Can anyone help me with this please?

This topic has been closed for replies.
Correct answer Bernd Alheit

You can use other values for the parameter "oCoords".

2 replies

try67
Community Expert
Community Expert
August 16, 2019

If you want to place the field under another field then you need to first read the rect property of the first field, adjust it by changing the y coordinates (1 and 3 in the rect array) to new values, and then use that when creating your new field.

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
August 16, 2019

You can use other values for the parameter "oCoords".

paulo55628202
Participant
August 18, 2019

Thank you both for your replies. Your solutions work for the first instance but how do you then add subsequent instances and then later remove them if they're not needed? I found how to unhide then hide a page which is sort of a solution but rather cumbersome, a row by row solution is what I'm striving for, maybe it's not possible with Acrobat DC?

try67
Community Expert
Community Expert
August 18, 2019

You need to either create the fields in advance and then show/hide them as needed, or add them (using addField) and delete them (using removeField) as needed. This is not a simple task, though, because each time you remove a field from the middle of the "table" you'll need to move all the ones after it up, to take its place.