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

Attach a file Button that shows the preview/file on the button(Box) they clicked on

Explorer ,
Aug 14, 2023 Aug 14, 2023

Copy link to clipboard

Copied

Okay, here is my situation.  I want to create a button that is interactive, but in a simple way.  Thanks to other forums, here's what I have done so far.  Go to Forms, Add button, size it and Save.  Then go to properties/Actions/Run A Javascript/Add and put input: if (app.viewerVersion < 11) etc.... OK then I go to Tools, Javascript/Document Javascript and put in my script.  Thanks to all in previous chats.  All of that works well.  The only one thing, I need now that will make it perfect, is to be able to preview the pdf/jpeg that I attachment as a small image as well as an attachment.  Now I did however find a way to do it using this: ( event.target.buttonImportFile();) but the only problem is that particular script attached to the button, causes the browse file search, to open twice to do 1 file.  Once to lock in the icon, then a 2nd time to attach the file.  So is there anyway to insert a script, in the open javascript button that will save the mini-image on the button  and save the attachment together as one?  Any help would be GREATLY appreciated.  See illustration for further details.Button Issues.jpg

TOPICS
General troubleshooting , How to , JavaScript , PDF

Views

2.0K

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 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

It should only take one selection. What exact code did you use?

And no, JS can't be used to display a preview thumbnail of the selected image. That's up to the application and/or the OS's file selection dialog.

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 ,
Aug 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

Hi Try 67, I must have found something, new.   As you see in the pic, my button does have a thumbnail .  As stated above I use 2 javascript entries.  The first one is clicking on the button, and under javascript I input the 1st script and the 2nd java entry is under the Document Javascripts ToolboxButton Explanation1.jpgDataJavascript1.jpgDataJavascript2.jpg.  See Attached forms for a more detailed explanation.  Thanks.

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 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

You'll need to share the file for further help, but from what I can see you've duplicated the code for selecting the image. It's very unlikely the file will be used in a version prior to XI, so you don't need the whole pre/post_11 functions. Keep just the first line of code, using buttonImportIcon.

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 ,
Aug 15, 2023 Aug 15, 2023

Copy link to clipboard

Copied

Probably so.  I will attach the files here.  Thanks for your assistance.

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 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

Like I said, keep just the first line and try it 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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

I assuming you are referring to the 1st Javascript line, under Run a javascript?
which is: event.target.buttonImportIcon();
I did just keep this.  It loads the thumbnail but does not load the file.  That defeats the purpose. When I view attachments, nothing has uploaded.   Unless I am missing something, that don't work.  Any other ideas? 

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 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

The image is imported fine for me. The preview for it can be seen in the OS dialog, if you have that option enabled.

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 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

To add attachments use the functions import_pre_11() or import_11()

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

Somehow I must not be understanding what you are referring to. When trying to do this, that does not work.  See attachment below.  Tell me what I am doing wrong here.ButtonProblems2.jpg

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

Using the: import_11(); Command works but back to the same problem.  I have to select my file twice, instead of once for thumbnail and then again for file attachment.  I need one click and done.

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 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

The attachment works for me. 

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

Which attachment exactly?  And can you give me the exact way you are inputing 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
Community Expert ,
Aug 17, 2023 Aug 17, 2023

Copy link to clipboard

Copied

It let me attach every file.

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 ,
Aug 17, 2023 Aug 17, 2023

Copy link to clipboard

Copied

LATEST

Thanks, for your response.  I need anyone else who can show me what they are putting in the script, so I can see where my error is.  As stated before, mine is not working the way I am inputing it in.  My other help would be appreciated.

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