• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Javascript not working in PDF

New Here ,
Aug 27, 2020 Aug 27, 2020

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!

TOPICS
Acrobat SDK and JavaScript

Views

1.8K

Translate

Translate

Report

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 ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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.

 

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Remove var from this line: 

var ar = v.split(",");

Votes

Translate

Translate

Report

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 ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Sorry, yes. Does it go in here: where the comma is"
ar = v.split(",");

[Private info removed. -Mod.]

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Use "\n".

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

"Sorry, yes. Does it go in here: where the comma is"
ar = v.split(",");

 

Yes.

 

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

LATEST

In place of the comma?

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Thanks, I did but it still does not reset unless the mouse moves and hovers over it. I appreciate your reply and help. any thoughts on separating each item to a new line? I tried /n but it just added /n, not a new line.




Trish Varga

Specialist, Functional Application Support

Application Programming Support

Pellissippi State Community College

10915 Hardin Valley Road

Knoxville, TN 37933 ā— 865-694-6409 ā— pavarga@pstcc.edu

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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. 

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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
Enthusiast ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

Do you have other calculations in file? If yes check field calculation order. 

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

No nothing.

[Private info removed. -Mod.]

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

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.)

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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>

 

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

This is an LCD form... You can't edit it in Acrobat.

Votes

Translate

Translate

Report

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
New Here ,
Aug 27, 2020 Aug 27, 2020

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.

Votes

Translate

Translate

Report

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