Skip to main content
Participant
October 2, 2018
Question

JavaScript Copying value from one text field to another

  • October 2, 2018
  • 1 reply
  • 510 views

I have created a button to run the following actions:

  1. Mouse Down > Execute a menu item > File>Print...
  2. Mouse Down > Run a JavaScript as follows

                                                  function copyToAnother()

                                                  {

                                                  var text1 = document.getElementById(id_of_first_text_field);

                                                  var text2 =document.getElementById(id_of_second_text_field);

                                                  text2.value = text1.value; // copy value of Ist field into second Field

                                                  }

        This is to try to copy a numerical vale from a text field (Text1) to another text field (Text2)

     3. Mouse Down > Reset a form (all fields except Text2)

     4.  I then want to use a JavaScript to autosave the form

     5.  When this saved file is opened, I  want to use a JavaScript to move the value from the Text2 field to the Text1 field

I would like to do this with using a global object for sequential numbering.  So far, my JavaScript doesn't seem to produce results.  Is there an easier way to accomplish the above tasks?

This topic has been closed for replies.

1 reply

Legend
October 2, 2018

2. getElementById is used in browser JavaScript, not in Acrobat JavaScript.

2. This is a function, you would need to call it (though it won't work)

Autosave is a serious problem, because you can download PDF files from the internet - they are not free to just save where they want.