Solved

Acroform Javascript-How to copy using a loop?

Posted on 2011-03-18
2
929 Views
Last Modified: 2012-05-11
Greetings All;

Using Adobe Acrobat v8.12 (for WIN)/Javascript how can I copy the semi-colon separated values of TEXTBOX1 into TEXTBOX2? (while adding a sequential ID in front of each copied values (minus the semi-colon)?

Copied values can be separated by a single blank space.

See illustraion below.

I have a working javascript for copying single or multiple selected values of a listbox into a textbox, but can't seem to get it modified correctly. HELLLLPPPPPP!

Thank you for you time and consideration.
´*•.¸(`*•.¸?¸.•*´)¸.•*´
?*°Doris 42DoubleDDs*°•´»?
.¸.•*(¸.•*´?`*•.¸) *•.¸

Listbox1 to Text1 Version

Custom calculate Keyboard Script in "text1" field:


var textFieldNewValue = ""
 
var f = this.getField("listbox1");
var a = f.currentValueIndices;
 
if (typeof a == "number") // A single selection
{
     textFieldNewValue = f.getItemAt(a, false);
}
else // Multiple selections
{
    console.println("Selection:");
    for (var i = 0; i < a.length; i ++)
    {
        if (i!=0)
        {
            textFieldNewValue += " ";
        }
         textFieldNewValue += f.getItemAt(a[i], false);
    }
}
 
event.target.value = textFieldNewValue;

Open in new window

EE-Acroform-Copy-Question-031911.jpg
EE-Acroform-Copy-Test-File.pdf
0
Comment
Question by:DMackallii
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35173852
Check this :


var s = this.getField("TEXTBOX1").value;
s = s.split(/;\s*\r*\n*/)

this.getField("TEXTBOX2").value = ""
for(var i=0;i<s.length;i++) {
  var p = ("000" + i);
  p = p.substr(p.length-4,4);
  if(i==0) {
     this.getField("TEXTBOX2").value += p + " " + s[i]; 
  }
  else {
     this.getField("TEXTBOX2").value += " " + p + " " + s[i]; 
  }
}

Open in new window

0
 

Author Closing Comment

by:DMackallii
ID: 35174009
leakim971...once again you make seem so easy!. THANK YOU so very much!. That's exacly what I was looking for.

´*•.¸(`*•.¸?¸.•*´)¸.•*´
?*°Doris 42DoubleDDs*°•´»?
.¸.•*(¸.•*´?`*•.¸) *•.¸
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question