?
Solved

Acroform Javascript-How to copy using a loop?

Posted on 2011-03-18
2
Medium Priority
?
931 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 2000 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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Check out the latest tech news, community articles, and expert highlights in August's newsletter.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

771 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