Copy link to clipboard
Copied
- I am a complete newbie to JavaScript and this is my first post. With the help of various snippets of script I have found on the web and Thom Parker's book "all about pdf stamps" I have created a custom dialogue to populate several text fields and tick boxes of a dynamic stamp. The stamp works well but it could be better. I would like the input fields on the custom dialogue to display default values rather than blank white space. I can get one field to display as I would like, but only the last of 7 fields does this. If I copy what I did in field 7 to the others it doesn't work for the others but field 7 does work. Can you help? I have 7 lines like this:
- strField1: "",
- initialize: function(dialog) {
- dialog.load({"fld1":this.strField1});
- },
- These lines are repeated with strField1 and fld1 replaced by strField2 to strField7 and fld2 to fld7 followed by the following script:
- commit:function(dialog) {
- var data=dialog.store();
- this.strField1=data["fld1"];
- Again this is repeated for the other fields as before.
- I changed strField7:"", to strField7:"something else", and it defaults to "something else" instead of white space and the stamp works whether the custom dialogue default value is left or it is typed over. But it only works with this last field. If I do exactly the same thing with the others I still get the blank white input box but no default. I hope this makes sense and somebody can help me with this.
1 Correct answer
You've over-complicated the code. Simply use this as the initialize function:
initialize: function(dialog) {
dialog.load({
"fld1":"1",
"fld2":"2",
"fld3":"3",
"fld4":"4",
"fld5":"5",
"fld6":"6",
"fld7":"7"
});
},
Copy link to clipboard
Copied
You've over-complicated the code. Simply use this as the initialize function:
initialize: function(dialog) {
dialog.load({
"fld1":"1",
"fld2":"2",
"fld3":"3",
"fld4":"4",
"fld5":"5",
"fld6":"6",
"fld7":"7"
});
},
Copy link to clipboard
Copied
Try67 I cannot thank you enough. I am a complete novice to JavaScript and do not fully understand it as you can tell. I am surprised I got this far before getting stuck. But I have seen the help you have given others. The speed with which you replied was phenomenal and the solution spot on. Many thanks.
Copy link to clipboard
Copied
Don't feel bad. Dialogs are one of the most complicated things one can do in Acrobat JS...
Copy link to clipboard
Copied
You'll find a drag and drop Dialog editor, and some tutorial vidoes, here:
https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm
If you have questions about these things, you should email or message me.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks, Glad to help
Use the Acrobat JavaScript Reference early and often

