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

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

Engaged ,
Mar 14, 2018 Mar 14, 2018

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
4.2K
Translate
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"]);

Translate
Engaged ,
Mar 14, 2018 Mar 14, 2018

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.

Translate
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

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

Translate
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

Your original script should have worked, too...

Translate
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

No,

my original script cleared both the fields....

Translate
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

Are those your actual field names?

Translate
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

yes, why? they are actual field names

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

Translate
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

Then it should have worked.

Translate
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

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

Translate
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

This script works.

Translate
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

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

Translate
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

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

Translate
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

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

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

Translate
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