Auto-create fields with same name using javascript
Copy link to clipboard
Copied
I am trying to run the following script as a Custom Command. My delimma is that only the first field is being generated. Two of my fields MUST have the same name due to an integration with another software platform. How do I get around this?
var sf = this.addField("Field_Name[0]", "signature", 0, [223,554,279,540]);
var sf = this.addField("Field_Name[0]", "signature", 0, [332,38,388,24]);
I seem to be able to create them manually just fine and Acrobat automatically differntiates both fields:
If I open Properties for both of the above fields, the name is indeed identical for both - Acrobat is not appending the #1 to the actual field name. I attached what I am talking about below: Sample.pdf
How do I achieve this same end using javascript?
Thanks in advance for the help and Happy New Year!
Copy link to clipboard
Copied
The "#1" part is not a part of the actual field name. It's how the user interface in Acrobat shows that the two fields share the same name, but are unique widgets, with the number being the index number of that widget in the field group. It should appear exactly the same, regardless of how the fields are created.
Copy link to clipboard
Copied
Thank you for your response. Yes, I understand that that is the effect when creating the fields manually. The question at hand is how to recreate that using javascript? The sample code above only results in one field being created rather than both. For some reason, Acrobat seems to ignore the second line of code and does not simply create a second field with the '#1' as Acrobat does when the fields are created manaually.
Copy link to clipboard
Copied
You can't create two signature fields with the same name.
Copy link to clipboard
Copied
Note that when you did it manually you created text fields. If you tried to do the same with signature fields, it won't work, either.

