Copy link to clipboard
Copied
Below is the JS that I am using but for some reason it is not incrementing on the fields. All the fields VOUCHERCOUNT values are the same. Attached is a screen shot. I have tired adding the increment both before and after the field being generated. I am trying to add the text fields on the even pages which I was able to do but I need the last part of this text to increment upwards. Any help is much appreciated as this is driving me crazy!! I am not sure if it is just something simple that I am missing.
SCHEDULE_NUMBER = this.getField("SCHEDULE_NUMBER").valueAsString;
VOUCHERCOUNT = this.getField("VOUCHERCOUNT").value;
for (var page = 0; page < this.numPages; page++) {
var numb = page+1;
if (numb%2 == 0) {
var firstpagecords = this.getPageBox("Crop",page);
Top = firstpagecords[1];
Midhoriz = firstpagecords[2]/2;
var ScheduleBox = this.addField("Textbox1", "text", page, [Midhoriz-200,Top-2,Midhoriz,Top-24]);
ScheduleBox.value = "L-" + SCHEDULE_NUMBER+ " / " + VOUCHERCOUNT;
ScheduleBox.textSize = 20;
ScheduleBox.textColor = color.red;
ScheduleBox.readonly = true;
VOUCHERCOUNT = VOUCHERCOUNT+1;
}
}
Copy link to clipboard
Copied
You're creating fields with same name and those fields will have same value, you need to create fields with unique names: "Textbox1", "Textbox2"...etc, try using this:
SCHEDULE_NUMBER = this.getField("SCHEDULE_NUMBER").valueAsString;
VOUCHERCOUNT = Number(this.getField("VOUCHERCOUNT").valueAsString)+1;
var textFieldCount = 1;
for(var page=0; page<this.numPages; page++){
var numb = page + 1;
if(numb % 2 == 0){
var firstpagecords = this.getPageBox("Crop", page);
Top = firstpagecords[1];
Midhoriz = firstpagecords[2] / 2;
var fieldName = "Textbox" + textFieldCount;
var ScheduleBox = this.addField(fieldName, "text", page, [Midhoriz - 200, Top - 2, Midhoriz, Top - 24]);
ScheduleBox.value = "L-" + SCHEDULE_NUMBER + " / " + VOUCHERCOUNT;
ScheduleBox.textSize = 20;
ScheduleBox.textColor = color.red;
ScheduleBox.readonly = true;
VOUCHERCOUNT++;
textFieldCount++;}}
Copy link to clipboard
Copied
You're creating fields with same name and those fields will have same value, you need to create fields with unique names: "Textbox1", "Textbox2"...etc, try using this:
SCHEDULE_NUMBER = this.getField("SCHEDULE_NUMBER").valueAsString;
VOUCHERCOUNT = Number(this.getField("VOUCHERCOUNT").valueAsString)+1;
var textFieldCount = 1;
for(var page=0; page<this.numPages; page++){
var numb = page + 1;
if(numb % 2 == 0){
var firstpagecords = this.getPageBox("Crop", page);
Top = firstpagecords[1];
Midhoriz = firstpagecords[2] / 2;
var fieldName = "Textbox" + textFieldCount;
var ScheduleBox = this.addField(fieldName, "text", page, [Midhoriz - 200, Top - 2, Midhoriz, Top - 24]);
ScheduleBox.value = "L-" + SCHEDULE_NUMBER + " / " + VOUCHERCOUNT;
ScheduleBox.textSize = 20;
ScheduleBox.textColor = color.red;
ScheduleBox.readonly = true;
VOUCHERCOUNT++;
textFieldCount++;}}
Copy link to clipboard
Copied
Great thank you Nesa! Worked perfectly!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more