Is is possible to replace the text in a texfield?

Explorer ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Hi everyone!

 

I´m trying to find a command that allows me to replace the original text  in a textfield, maybe

thru a button. The change in the text may be triggered by a user´s input in another textfield

or a button click.

Thanks a lot for your great help, in advance!!

TOPICS
Create PDFs, JavaScript, PDF forms

Views

123

Likes

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
Most Valuable Participant ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Sure, that's possible. The basic command to do it is this:

this.getField("FieldName").value = "New field value";

If you want to copy the value of another field into it you can do it like this:

this.getField("FieldName").value = this.getField("OtherFieldName").value

Likes

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
Explorer ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Thank you very much!!

I suppose the second option could also be used to replace images, but my concern is if I have to store the images to be replaced somewhere or just hide the new image field and use (display.visible) to make it appear.

Likes

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
Most Valuable Participant ,
Apr 05, 2021 Apr 05, 2021

Copy link to clipboard

Copied

Not quite, no. Images are not saved as the value of a regular field. They are saved as the icon of a button field, but copying them requires a different set of commands.

Here's how you would copy an image from Button2 to Button1:

 

this.getField("Button1").buttonSetIcon(this.getField("Button2").buttonGetIcon());

Likes

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
Explorer ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

LATEST

Thank you! I´m going to try this script.

 

Likes

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