Highlighted

JavaScript in PDF - 2 dropdown menus with autofilling multiple fields

New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

Hi there,

I created a PDF document with several fields getting autofilled by a javascript code. The file has two dropdown menus and several textfields.

A selection in the first dropdown menu autofills 2 different textfields via "SetFieldValues".

A selection in the second dropdown menu autofills 1other textfield via "SetFieldValues".

Everything worked fine, but out of a sudden a selection in the first dropdown menu doesn't do anything.

 

The debugger tells me this: "TypeError: variable-name[function-name] is undefined
10:Field:Keystroke".

An online editor gives the following error: "error: unknown: Identifier 'SetFieldValues' has already been declared"

 

I gave both dropdown menus the following user defined format: "SetFieldValues(event.value)".

What went wrong here? Please help!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

You can use e.g. the names SetFieldValues1 and SetFieldValues2 for the functions.

Then you can use SetFieldValues1(event.value)  and SetFieldValues2(event.value).

TOPICS
PDF forms

Views

66

Likes

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

JavaScript in PDF - 2 dropdown menus with autofilling multiple fields

New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

Hi there,

I created a PDF document with several fields getting autofilled by a javascript code. The file has two dropdown menus and several textfields.

A selection in the first dropdown menu autofills 2 different textfields via "SetFieldValues".

A selection in the second dropdown menu autofills 1other textfield via "SetFieldValues".

Everything worked fine, but out of a sudden a selection in the first dropdown menu doesn't do anything.

 

The debugger tells me this: "TypeError: variable-name[function-name] is undefined
10:Field:Keystroke".

An online editor gives the following error: "error: unknown: Identifier 'SetFieldValues' has already been declared"

 

I gave both dropdown menus the following user defined format: "SetFieldValues(event.value)".

What went wrong here? Please help!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

You can use e.g. the names SetFieldValues1 and SetFieldValues2 for the functions.

Then you can use SetFieldValues1(event.value)  and SetFieldValues2(event.value).

TOPICS
PDF forms

Views

67

Likes

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
Jul 30, 2020 0
Adobe Community Professional ,
Jul 30, 2020

Copy link to clipboard

Copied

Where have you defined the function SetFieldValues?

Likes

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
Reply
Loading...
Jul 30, 2020 0
New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

Under "Format" and then "User defined keystroke input" of both dropdown menu fields.

German: Format - Benutzerdef. Tasteneingabeskript.

Likes

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
Reply
Loading...
Jul 30, 2020 0
Adobe Community Professional ,
Jul 30, 2020

Copy link to clipboard

Copied

You use 2 different functions with the same name?

Likes

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
Reply
Loading...
Jul 30, 2020 0
New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

In case of the "SetFieldValues(event.value)", yes I suppose *turns red*

I'm a js noob and the strange thing is, that the PDF was working as intended. For me and a collegue. 

Anyway, how can I resolve the error?

Likes

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
Reply
Loading...
Jul 30, 2020 0
Adobe Community Professional ,
Jul 30, 2020

Copy link to clipboard

Copied

Use different names for the functions.

Likes

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
Reply
Loading...
Jul 30, 2020 0
New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

So I need to specify both "events", right?

If yes, how to?

Likes

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
Reply
Loading...
Jul 30, 2020 0
Adobe Community Professional ,
Jul 30, 2020

Copy link to clipboard

Copied

You can use e.g. the names SetFieldValues1 and SetFieldValues2 for the functions.

Then you can use SetFieldValues1(event.value)  and SetFieldValues2(event.value).

Likes

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
Reply
Loading...
Jul 30, 2020 1
New Here ,
Jul 30, 2020

Copy link to clipboard

Copied

That did the trick 🙂

Thank you very much!

 

It remains a mystery why that worked on 2 different machines... 😄 nevermind

Likes

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
Reply
Loading...
Jul 30, 2020 0