• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
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

3.0K

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

Engaged , 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"]);

Votes

Translate

Translate
Engaged ,
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.

Votes

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
Engaged ,
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"]);

Votes

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

Copy link to clipboard

Copied

Your original script should have worked, too...

Votes

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

Copy link to clipboard

Copied

No,

my original script cleared both the fields....

Votes

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

Copy link to clipboard

Copied

Are those your actual field names?

Votes

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

Copy link to clipboard

Copied

yes, why? they are actual field names

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

Votes

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

Copy link to clipboard

Copied

Then it should have worked.

Votes

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
Engaged ,
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

Votes

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

Copy link to clipboard

Copied

This script works.

Votes

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
Engaged ,
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"]);

Votes

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

Copy link to clipboard

Copied

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

Votes

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
Engaged ,
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

Votes

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
Community Expert ,
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.

Votes

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