• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

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

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

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

correct answers 1 Correct answer

Community Expert , Feb 13, 2018 Feb 13, 2018

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 

Votes

Translate

Translate
Community Expert ,
Feb 13, 2018 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?

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

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

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

Copy link to clipboard

Copied

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

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

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

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

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

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
Explorer ,
Feb 19, 2018 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?

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

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

Copy link to clipboard

Copied

LATEST

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

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