Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 484
  • Last Modified:

Clipboard question

Is there anyway to place the contents of a textbox into the clipboard after a radio or checkbox is clicked using acrobat's javascript functions ?
0
jerrycsakanyjr
Asked:
jerrycsakanyjr
  • 4
  • 4
1 Solution
 
Karl Heinz KremerCommented:
I don't think so: You don't have access to any selection routines. So even if you would manage to execute the menu item to copy the current selection, you would not have any control over what's actually selected.

What do you want to accomplish? There may be other ways to end up with the same results, but use a different method.
0
 
jerrycsakanyjrAuthor Commented:
I would like to do something like this... I have 2 text boxes one with a persons name and one with a social security number. If the social security number has a value in it copy it to the clipboard, if the social security number is empty or has a value of  "" then  copy the value of the person's name to the clipboard starting after the first space.
Example
textbox  1 called :  name
textbox 2 called  : social

If  socials.value = null or empty or "" then
copy name.value to clipboard starting after 1st occurance of " "

else copy social.value to clipboard

So i can paste it into a search field in internet explorer which i will do with a CTRL + V


0
 
Karl Heinz KremerCommented:
Let's assume you have a button that you cant to press in order to copy the contents, you could use something like this:

var social = this.getField("social");
var name = this.getField("name");

if (social.value != "")
    social.setFocus();
else
    name.setFocus();

app.alert("Copy to clipboard");

app.execMenuItem("Copy");
// end of script

... and it will copy either the contents of the social or name field to the clipboard. However, the whole thing stops to work when you take out the alert box. It looks like you need a change of focus from some other window to the PDF document before the copy operation actually works.

Looks like you are out of luck this time (or you need to do the "Copy" operation manually as well and just use the logic in your form to select the correct field to copy from).
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
jerrycsakanyjrAuthor Commented:
That worked, but when it set focus it took out the "-" in the social security number . Is there any way to get them back in ?
0
 
jerrycsakanyjrAuthor Commented:
Nevermind i changed the format to do an arbutrary match instead of using the social security format. I just put in 999-99-9999
Thanks a bunch.
0
 
Karl Heinz KremerCommented:
I just wanted to tell you that it works for me :-)
0
 
jerrycsakanyjrAuthor Commented:
Why do u have to use the alert for it to work ?
0
 
Karl Heinz KremerCommented:
I don't know. When I first tried it without the alert, I was not able to get it to work. It did however work if I did the Ctrl-C manually after the JavaScript selected the field contents. My assumption was that the contents may not be selected at the time Acrobat calls the menu item (e.g. that it only updates the selection after the complete JavaScript is executed), so I added the alert box to see if the field contents were selected. ... and then it worked.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now