Solved

Acroform Javascript-How to copy using a loop?

Posted on 2011-03-18
2
921 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
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now