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

Having field data auto-populate in a read only field later on

Guest
Jun 20, 2016 Jun 20, 2016

Hello,

I'm trying to create a part of my form where the user fills in a value (a number) to a text box field and that value is automatically populated in a read-only text box in a later part of the form. The read-only text should adjust as the user adjusts the original text, but it shouldn't be able to be adjusted itself (hence the read-only).

I haven't figured out a way to make this work (actions? calculate?) and none of the forums I've found seem to address this. I'm assuming I shouldn't just name them the same thing because then they will both have to be adjustable or read-only.

If someone knows how this can be done please let me know! Thank you all in advance!

TOPICS
Acrobat SDK and JavaScript
1.1K
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

LEGEND , Jun 20, 2016 Jun 20, 2016

Use the Validate event of the input field, something like:

// Copy this field value to the other field

getField("Text2").value = event.value;

but replace "Text2" with the actual name of the read-only field.

Translate
LEGEND ,
Jun 20, 2016 Jun 20, 2016

Use the Validate event of the input field, something like:

// Copy this field value to the other field

getField("Text2").value = event.value;

but replace "Text2" with the actual name of the read-only field.

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
Guest
Jun 20, 2016 Jun 20, 2016

Thank you for the reply! I may not understand your answer completely, but it doesn't seem to be working. For example, in a budgeting form, I have an area the user can type in the amount spent - say on "groceries" - and later on it will compare the actual amount spent vs the amount budgeted.

I want the user to be able to enter in the amount budgeted for and later on, I want that amount (in a non-editable, read-only text box) to show up when compared with the actual amount spend. So, there will be an original box titled "Groceries" and a box later titled "GroceriesB" (B for budgeted which should be the read-only value from "Groceries") and "GroceriesA" (A for actual which will be a user input box for the actual amount spent on groceries).

In the GroceriesB validate tab I tried doing:

getField("GroceriesB").value = event.value;

But that did not work. I tried typing that into the "Groceries" validate tab but that also did not work. I tried replacing "event" with "Groceries" but that also still did not work.

Is there something I'm missing? Please let me know. Thank you again!

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
LEGEND ,
Jun 20, 2016 Jun 20, 2016

In your specific case, the Validate script for the Groceries field should be:

// Custom validate script for "Groceries" text field

getField("GroceriesB").value = event.value;

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
LEGEND ,
Jun 20, 2016 Jun 20, 2016

Also, be sure to remove any validate, calculate, or any other scripts you may have added to the GroceriesB field.

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
Guest
Jun 20, 2016 Jun 20, 2016

Thank you again for the response!

Hmm... still doesn't seem to be working. If the GroceriesB field is formatted (as a number with a dollar sign) could that be an issue?

Also, would it be impossible to do this if the field is calculated? For example, if Groceries was not a user-input number but instead a read-only calculated number that was the sum of things like "milk, eggs, bread, etc" that the user input values for?

Thank you again, I appreciate it!

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
Guest
Jun 20, 2016 Jun 20, 2016

Nevermind, the script IS working - it had just erased what I had input into the form when I changed it. I will work on the other question in the mean time. Thank you again!

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
Guest
Jun 20, 2016 Jun 20, 2016
LATEST

Looks like it's working even with calculated numbers! Thank you again!

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