Pdf form script to clear a text field and copying value with same button.

Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

I want a single button in pdf form to perform the below task:

Copy the value of the first text field to second field and  then reset the first field without changing the value of second field to which the original value was copied.

I used the following script but it resets the both fields;

first field = Text1;

Second field = Text2;

script:

this.getField("Text2").value = this.getField("Text1").value;

resetForm(["Text1"]);

thanks

TOPICS
Acrobat SDK and JavaScript, Windows

Views

781

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

correct answers 1 Correct Answer

Contributor , Mar 14, 2018 Mar 14, 2018
sorry for disturbing... finally i got it working. with below script :document level script:function one(){this.getField("Text2").value = this.getField("Text1").value;}this script in button:one();resetForm(["Text1"]);

Likes

Translate

Translate
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

I also tried the below script :

function one()

{

this.getField("Text2").value = this.getField("Text1").value;

}

resetForm(["Text1"]);

but this also didnot worked.. it cleared both fields.

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

sorry for disturbing... finally i got it working. with below script :

document level script:

function one()

{this.getField("Text2").value = this.getField("Text1").value;

}

this script in button:

one();

resetForm(["Text1"]);

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

Your original script should have worked, too...

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

No,

my original script cleared both the fields....

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

Are those your actual field names?

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

yes, why? they are actual field names

Text1, Text2............... Text25

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

Then it should have worked.

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

no my original script didnot worked

this.getField("Text2").value = this.getField("Text1").value;

resetForm(["Text1"]);

The above script reset both the fields .... i wanted once the value was copied it should not reset,, but the above script reset both the fields

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

This script works.

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

My requirement was :  I had two text fields  and one button . I wanted  the button to copy the value of first text field to second text field and reset the first field when the button is clicked.

below script didnot worked :

this.getField("Text2").value = this.getField("Text1").value;

resetForm(["Text1"]);

below script worked  :

document level script:

function one()

{this.getField("Text2").value = this.getField("Text1").value;

}

this script in button:

one();

resetForm(["Text1"]);

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

Works just fine. See: Reset button test.pdf - Google Drive

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
Contributor ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

yes, the original is also working but when i use it to my form it resets boths fields.. strange

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
Adobe Community Professional ,
Mar 14, 2018 Mar 14, 2018

Copy link to clipboard

Copied

LATEST

If you want to share it (like I did, using something like Dropbox, Google Drive, Adobe Cloud, etc.), I'm happy to take a look at why it's not working.

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