ComboBox drop down on multiple pages how to break associativity

Hello All,

I am working on a script that takes a multi page pdf and adds a next page button and a combobox drop down to select an A thru Z value. I have the script almost working. Am having difficulty braking the associativity of the combobox, if I change one all the pages change.

How can I separate the comboboxes so each page has a unique value selected?

Page1 A
Page2 A
Page3 G
Page4 M
Page5 A
ect.

//populates all pages,next page arrow working, error all drop down values linked

//Create page forward on the SL: text
var inch = 72;
 for (var p = 0; p < this.numPages; p++) {
  // Position a rectangle (.5 inch, .5 inch)
  var aRect = this.getPageBox( {nPage: p} );
  aRect[0] += 3.6*inch; // from upper left hand corner of page.
  aRect[2] = aRect[0]+.5*inch; // Make it .5 inch wide
  aRect[1] -= 2.2*inch;
  aRect[3] = aRect[1] - 24; // and 24 points high

  // Now construct a button field with a right arrow from ZapfDingbats
  var f = this.addField("NextPage", "button", p, aRect )
  f.setAction("MouseUp", "this.pageNum++");
  f.delay = true;
  f.borderStyle = border.s;
  f.highlight = "push";
  f.textSize = 0; // Auto-sized
  f.textFont = font.ZapfD
  f.buttonSetCaption("\341") // A right arrow
  f.delay = false;



//combo box for REV level
var name = "comborev";
var type = "combobox";
var location = [290, 602, 315, 588];
var myButton = this.addField(name, type, p, location);
myButton.editable = true;
myButton.setItems( ["A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]);
myButton.textSize = 10;
myButton.editable = true;
myButton.fillColor = color.white;
}


Thanks in advance

JohnC


John Coulston


4 Answers

Voted Best Answer

Change:

var name = "comborev";

To:

var name = "comborev_"+i;


By Gilad D (try67)   

You need to give each field a unique name. For example, you can include the page number in the name.

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


Gilad D (try67)   

Thanks for the reply Gilad.

I can change the field name with the form tools after I run the script and it works however; I am not able to figure out how to create a unique field name wiht the script.

I see in the Fields tree that the name looks as follows even though all the fields are name "name".
name#1
name#2
name#3

How do I append the page number to the name? I have been trying the following thoughts but they keep crashing Acrobat.


for (var i = 0; i < this.numPages; p++)

var name = "comborev";
var type = "combobox";
var location = [290, 602, 315, 588];
var myButton = this.addField("name+i", type, p, location);

or along this corse?

for (var i = 0; i < this.numPages; p++)
var name1= var i
var name = name_name1
var name = "comborev";
var type = "combobox";
var location = [290, 602, 315, 588];
var myButton = this.addField("name", type, p, location);


I understand that I need to have each field name unique, name_1, name_2. I dont know how to script it to combine variable names.

Thank you,


John Coulston   

Thank you for your help worked great.

//combo box for REV level
var name = "comborev_"+p;
var location = [290, 602, 315, 588];
var revlevel = this.addField(name, "combobox", p, location);
revlevel.editable = true;
revlevel.setItems( ["-", "A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]);
revlevel.textSize = 10;
revlevel.editable = true;
revlevel.fillColor = color.white;


John Coulston   


Please specify a reason: