Copy link to clipboard
Copied
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!
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Also, be sure to remove any validate, calculate, or any other scripts you may have added to the GroceriesB field.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Looks like it's working even with calculated numbers! Thank you again!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now