Copy link to clipboard
Copied
For some reason, text added to a pre-populated text field disappears when the fields on the page are set to read only. This happens on every page spawned, except the first page.
I have a form setup where users can spawn a new page to enter information for multiple instances. The form has a textarea that prepopulates with several lines of text. I wish for these lines to remain so the users can type next to the text already there.
The text are categories like: Name, Email, Phone (etc...)
I use a dropdown field to populate the text. It is in a Custom Validation Script in the dropdown field (I've found that if I put the text in a Custom Format script in the text field itself, the entire text disappears when you click in that field).
var v = event.value;
var f = this.getField("0Work notes");
f.value = "Name: \nEmail: \nPhone: \nWorking Hours: \n";
When the user types into the field, they just add data after the item category. At the bottom of the page, I have a button that they can click to get a new page for another contact. In addition to creating a new page, the button sets all of the just-filled-in page's fields to read-only. Then a new blank page with the form is added. The 1st page works beautifully.
New pages are spawned from my form. On the new pages, any text added to the field is lost and the the field gets reset to the pre-populated text when the page's fields are set to read-only. The calculation script is identical in the form the pages are spawned from, with the exception of the the text field's identity. I get information about the page number so the correct field name is used.
//Get page number
var currentPage = this.pageNum;
var v = event.value;
var f = this.getField("P" + currentPage + ".Form.Work notes");
f.value = "Name: \nEmail: \nPhone: \nWorking Hours: \n";
At this time, only the pre-populated text gets saved when the page fields are set to read-only and a new page is spawned. Any suggestions would be greatly appreciated.
All you need to do is set that string as the field's default value. You don't need (and shouldn't use) any custom Format, Validation or Calculation scripts.
Copy link to clipboard
Copied
Why does you use a dropdown list? You never use event.value
Copy link to clipboard
Copied
Your code will overwrite any value the user enters into the script. Why Are you doing it like that? Either apply a fixed value to the field and set it as read-only, or remove the code and allow the user to enter a value manually. If you want to modify the value the user enters use a Format script, but don't overwrite it.
Copy link to clipboard
Copied
What I'm trying to do is prompt the user to add the appropriate text in a field next to the label. I don't want to use individual text fields, because the user will eventually do a "copy all" from the textarea, including the label and the data they add. I don't want to overwrite what they add, I want to set it to readonly, so they can't change it after the fact. I need the labels in the textarea so they input the data where it needs to be.
This is the prepopulated text field:
This is the field, after a user has added information, and spawned a new page. The new page has a new fillable textarea, while the page just filled in is set to read-only so the data can't be changed.
I'm sure there's a better way to do this, I just don't have that much experience with this. I have searched through Adobe's site, and others, looking for similar issues where a solution was found. Not really finding this exact issue in my searches. Interestingly, this works on the "0" page, but any pages spawned from the template don't work.
I'm very open to any suggestions.
Thanks,
Laner
Copy link to clipboard
Copied
All you need to do is set that string as the field's default value. You don't need (and shouldn't use) any custom Format, Validation or Calculation scripts.
Copy link to clipboard
Copied
Perfect, try67! This is an instance of me trying to complicate things when the answer is not complicated! So sorry to be obtuse.
With this resolved, I only have one issue left on my form. I'll leave that for another post. :{
Regards!
Laner