How to change a javascript for websites into a javascript that works in acrobat?

Feb 13, 2018

Copy link to clipboard

Copied

Hello everybody,

I have attached a script that I would like to integrate into a PDF. The PDF has a textfield (called: input) to which I want to assign this script. Can anyone help me to embed this script? It works flawlessly via the browser. How can I use this script for websites in Acrobat? I have no experience with javascript in Acrobat, only a little using javascript in websites.

Thank you very much

Here is my script I want to include:

https://www.w3schools.com/howto/howto_js_autocomplete.asp

Yeah - I saw that when I looked again. I saw the PHP reference and thought it was happening on the server. How familiar are you with JavaScript. If you are familiar, look at the setItems method for a combo box field. Just filter the array by the value of the field after reach keystroke event.

Acrobat DC SDK Documentation 

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

405

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

How to change a javascript for websites into a javascript that works in acrobat?

Feb 13, 2018

Copy link to clipboard

Copied

Hello everybody,

I have attached a script that I would like to integrate into a PDF. The PDF has a textfield (called: input) to which I want to assign this script. Can anyone help me to embed this script? It works flawlessly via the browser. How can I use this script for websites in Acrobat? I have no experience with javascript in Acrobat, only a little using javascript in websites.

Thank you very much

Here is my script I want to include:

https://www.w3schools.com/howto/howto_js_autocomplete.asp

Yeah - I saw that when I looked again. I saw the PHP reference and thought it was happening on the server. How familiar are you with JavaScript. If you are familiar, look at the setItems method for a combo box field. Just filter the array by the value of the field after reach keystroke event.

Acrobat DC SDK Documentation 

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

406

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
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

The functionality is certainly possible in Acrobat javascript. However, the script you reference is essentially useless for Acrobat though. The object and event models are completely different and you'll need to recreate the functionality from scratch. The only major question I have is this... do you need the array of countries to be read from a server, as in your example, or can they be embedded in the JavaScript code?

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...
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

thanks for your message so quickly. No the array of countries should be embedded in the JavaScript code.

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...
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

Yeah - I saw that when I looked again. I saw the PHP reference and thought it was happening on the server. How familiar are you with JavaScript. If you are familiar, look at the setItems method for a combo box field. Just filter the array by the value of the field after reach keystroke event.

Acrobat DC SDK Documentation 

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...
Feb 13, 2018 1
Feb 13, 2018

Copy link to clipboard

Copied

oh sorry, I think I am not familiary enough for that... I'm still learning.

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...
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

oh, I see! I will have a look at the setItems method for a combo box field at thursday. I think this will help me, but first I have to sleep. Thank you very much so far, I think, this wasn't my last question in that theme...

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...
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

Actually, it looks like at some point the standard combo box just does this automatically. Just be sure to tick off the box to allow custom text. No programming required.

Screenshot 2018-02-13 14.07.54.png

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...
Feb 13, 2018 0
Feb 13, 2018

Copy link to clipboard

Copied

it works so far. But if I click on 'allow custom text' I can write everything I want into the box, also terms that are not in the list... And than I have no more autocomplete-function. I think I will try it tomorrow again,

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...
Feb 13, 2018 0
Feb 15, 2018

Copy link to clipboard

Copied

Hi Joel, it works!!!!! I can't say, how happy I am! You're the greatest 🙂 thank you so much.

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...
Feb 15, 2018 0
Feb 19, 2018

Copy link to clipboard

Copied

Hi Joel,

I thought your answer would have answered my question. But I am desperate: I have created a combobox (with about 50 input values) and a text box in which the export values should appear. When I say "Allow user to enter custom text" the user can enter free text. But I do not want that. I want it to look like this in my example link (https://www.w3schools.com/howto/howto_js_autocomplete.asp) and it does not do that 😞 if I enter a "f" for example, Acrobat will not show me all words  starting with "f" ... A user does not want to scroll 50 words until he comes to the z. And if I let him enter freely I can define no export value for it.

Can you help me please please please?

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...
Feb 19, 2018 0
Feb 19, 2018

Copy link to clipboard

Copied

It's not going to work exactly the same way in Acrobat. To make the drop down filter the list based on user input, you need to allow the user to enter a value into the field but before that, the user needs to click the little arrow down, then start typing. It's not as intuitive but it does work.

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...
Feb 19, 2018 1
Feb 20, 2018

Copy link to clipboard

Copied

Thank you for your renewed help. I'll do it this way for now. Maybe later I will find a more elegant version with javascript. Thanks and all the best for you

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...
Feb 20, 2018 0