Copy link to clipboard
Copied
I have a fillable PDF with a dropdown. I followed advice I saw on here and I have a text box that each selection is saved to. But the dropbox always shows the last selection rather than resetting. I have tried many things and cannot figure it out. I used actions for mouse enter and reset a field but only the one field.
I used run Javascript and entered a line to reset. I tried mouse exit, up, down, onfocus annd blur just for the heck of it.
An analyst from my department spend a couple hours on it too and he said it is set right but it is not doing what it is told.
The closest it gets is it resets when the mouse gets near it afterwards. Like it works like a hover not a click.
I also wondered if I could have each selection on its own line in my testbox. Currently it is separated by a comma and wraps unevenly at the end of the line.
I have to turn this over to an end user and I hate to give it so messy.
Thanks much!
Copy link to clipboard
Copied
1. If you want us to make suggestions about what is wrong with code, it helps to share it! Please share your exact code for people to try, because the problem is often not where you think it is.
2. Please confirm you have checked the JavaScript console and there are no error messages there. Or if there are messages please share them.
Copy link to clipboard
Copied
Thanks I will. This is my first attempt for help on here. Can I upload the file?
This is under all Javascripts:
/
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<Document-Level>
//<ACRO_source>dropdown</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:dropdown ***********/
function UpdateTextField(doc, fieldName, newValue)
{
var ar = [];
// Get the values currently stored in the text field and
// convert them to an array
var v = doc.getField(fieldName).value;
if (v.length > 0) {
var ar = v.split(",");
}
// Do we already have newValue in the array?
var foundIt = -1;
for (var i=0; i<ar.length; i++) {
if (ar[i] == newValue) {
foundIt = i;
break;
}
}
if (foundIt != -1) {
// remove the item
ar.splice(i, 1);
}
else { // add the item at the end
ar.push(newValue);
}
// If we have more than four elements,
// remove the oldest one
while (ar.length > 4) {
ar.shift();
}
// conver the array to a string
this.getField(fieldName).value = ar.join();
}
//</ACRO_script>
//</Document-Level>
//<AcroForm>
//<ACRO_source>ddtype:Validate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ddtype:Validate ***********/
UpdateTextField(this, "Text1", event.value);
//</ACRO_script>
//</AcroForm>
/*********** belongs to: AcroForm:ddtype:Validate ***********/
UpdateTextField(this, "Text1", event.value);
//</ACRO_script>
//</AcroForm>
This is in the Action tab of the DD:
I have selected Mouse Enter as my trigger and run a JavaScript as Action.
this.resetForm(["ddtype"]);
This is in Validate:
I have also checked Run a custom validation script.
UpdateTextField(this, "Text1", event.value);
Debugger is blank.
Copy link to clipboard
Copied
Remove var from this line:
var ar = v.split(",");
Copy link to clipboard
Copied
It's \n not /n. See https://mathiasbynens.be/notes/javascript-escapes
Copy link to clipboard
Copied
Sorry, yes. Does it go in here: where the comma is"
ar = v.split(",");
[Private info removed. -Mod.]
Copy link to clipboard
Copied
Use "\n".
Copy link to clipboard
Copied
"Sorry, yes. Does it go in here: where the comma is"
ar = v.split(",");
Yes.
Copy link to clipboard
Copied
In place of the comma?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I notice that there are two copies of the Validate script for "ddtype", which is not normal. Did you edit the code via Edit All JavaScripts? If so, you might have caused irreparable damage to the file and will have to start over from a fresh copy of it.
Copy link to clipboard
Copied
It has a ton of fields etc. Can I copy and paste without hurting anything? also never edited that spot, just behind the field. Sorry for the contact info, did not know I could not reply from my email.
Copy link to clipboard
Copied
If you didn't edit it from there it should be fine. I just got suspicious because that part appears twice... Is it actually like that, or did you just copy it twice to your reply?
You can reply by email, just make sure it doesn't include your private details.
Copy link to clipboard
Copied
It is there twice. Is it always bad to edit there? It says it is an edit ecreen. But I saw that too and wondered. I thought maybe there was a bug in Adobe and if I could find the code for doing this somewhere else I could not use the action tab since it does not seem like it is working.
Copy link to clipboard
Copied
Yes, very bad. And the name is indeed confusing. You should also not copy the code from there to another file. Best to avoid it altogether, really.
Copy link to clipboard
Copied
Do you have other calculations in file? If yes check field calculation order.
Copy link to clipboard
Copied
No nothing.
[Private info removed. -Mod.]
Copy link to clipboard
Copied
(Each time you reply by email it includes your full contact details in the signature. You should avoid doing that.)
Copy link to clipboard
Copied
I decided to create a new form and just copied the dropdown and its text field in to it.
This is now in debugger: Does it have any importance?
TypeError: this.getField is not a function
1:XFA:form1[0]:#subform[0]:Header[0]:Body[0]:Type[0]:exit
ReferenceError: UpdateTextField is not defined
2:Field:Validate
ReferenceError: UpdateTextField is not defined
2:AcroForm:ddtype:Validate
Copy link to clipboard
Copied
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<AcroForm>
//<ACRO_source>ddtype:Annot1:MouseEnter:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ddtype:Annot1:MouseEnter:Action1 ***********/
this.resetForm(["ddtype"]);
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>ddtype:Validate</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:ddtype:Validate ***********/
UpdateTextField(this, "Text1", event.value);
//</ACRO_script>
//</AcroForm>
Copy link to clipboard
Copied
This is an LCD form... You can't edit it in Acrobat.
Copy link to clipboard
Copied
I am sorry, I do no tknow what that means. It will allow me to edit. I have had LiveCycle forms I cannot edit in Acrobat but I am phasing them out. This one actually was one that I had to print to PDF and put all my fields back in.