Copy link to clipboard
Copied
I have a fillable PDF where there is a column where I want to be able to auto populate sequentially the rest of the boxes in that field set based on the first field entry.
Copy link to clipboard
Copied
Yes, this is possible with a script. From the image I'm assuming that the Order Number column is the one you want automatically populated? Will the user always be starting on the first line, or can the auto numbering start at any line? Does the user enter the order number? or is it automatically set from some other source?
Copy link to clipboard
Copied
The first "order number" field will be manually filled and I wish for each order number field to increment by one to the bottom of the sheet. This whether the sheet starts at 1 or 511.
Copy link to clipboard
Copied
Would someone be able to show me an example of a incremental couter script? I have tried a few things that I found on the internet and I am wondering if it's just my implementation that is failing me.
Copy link to clipboard
Copied
The best approach is to use a Validate script on the "OrderNumber 1" field. Then make all the other OrderNumber fields read only.
// Custom Validate script
if(Number.isInteger(Number(event.value))
{
var nInc = Number(event.value);
for(var i=2;i<=nRows;i++)
{
this.getField("OrderNumber " + i).value = ++nInc;
}
}
else
{
event.value = "";
app.alert("Entered Value must be an Integer");
}
Copy link to clipboard
Copied
Thank you, I will try this in the morning! I'll report as to my results.
Copy link to clipboard
Copied
Getting an error about bad syntax missing a ) after condition 3 at line 4....
Copy link to clipboard
Copied
Correction, missing final ")" in first line
// Custom Validate script
if(Number.isInteger(Number(event.value)))
{
var nInc = Number(event.value);
for(var i=2;i<=nRows;i++)
{
this.getField("OrderNumber " + i).value = ++nInc;
}
}
else
{
event.value = "";
app.alert("Entered Value must be an Integer");
}
Copy link to clipboard
Copied
As soon as I add a number to define the rows (changing nRows to say 24Rows)
It returns " SyntaxError: identifier starts immediatelyu after numeric literal
5: at line 6
😞
Copy link to clipboard
Copied
I did not include a definition of "nRows". It has to be a number equal to the number of fields in the column
Here's an update.
// Custom Validate script
if(Number.isInteger(Number(event.value)))
{
var nRows = 24;
var nInc = Number(event.value);
for(var i=2;i<=nRows;i++)
{
this.getField("OrderNumber " + i).value = ++nInc;
}
}
else
{
event.value = "";
app.alert("Entered Value must be an Integer");
}
Copy link to clipboard
Copied
Thank you for your help Mr. Parker. This has been a great learning experience.