Copy link to clipboard
Copied
I am very new to this but trying to learn. The task I've been given is this:
I feel like it's getting close but just can't get there. Any and all help will be greatly appreciated!
var Dlg =
{
description:
{
name: "Select File To Open",
elements:
[
{
type: "view",
elements:
[
{
item_id: "Header1",
name: "Select Document To Open",
type: "static_text",
},
{
item_id: "Button1",
name: "IOM",
type: "button",
Button1:function(dialog)
{
app.openDoc("/IOM/IOM.pdf", this);
},
},
{
item_id: "Button2",
name: "Submittal",
type: "button",
},
{
item_id: "Button3",
name: "Owner's Manual",
type: "button",
},
{
item_id: "Button4",
name: "Test & Balance",
type: "button",
}
]
},
{
type: "ok",
ok_name: "Close"
},
]
}
};
app.execDialog(Dlg);
You can use check-boxes in your dialog where the user can select which file(s) to open, and after they close the dialog you can open the selected files.
Copy link to clipboard
Copied
You can't do it. Dialog objects are modal. You can't tell the app to open
new documents while they are still open.
On Wed, Mar 30, 2016 at 8:37 PM, jmarshallinc <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Is there anything else that would work? We just don't want 4 separate buttons on the page because this will have to be done several times on each page. Thanks
Copy link to clipboard
Copied
You can use check-boxes in your dialog where the user can select which file(s) to open, and after they close the dialog you can open the selected files.
Copy link to clipboard
Copied
Thank you very much try67!
Copy link to clipboard
Copied
What about radio buttons? This is what I've done but it's not working, probably have something in the wrong place.
var docType
var Dlg ={
description:
{
name: "Select File To Open",
elements:
[
{
type: "view",
elements:
[
{
item_id: "Header1",
name: "Select Document To Open",
type: "static_text",
},
{
item_id: "Button1",
name: "IOM",
type: "radio",
group_id: "rd",
},
{
item_id: "Button2",
name: "Submittal",
type: "radio",
group_id: "rd",
},
{
item_id: "Button3",
name: "Owner's Manual",
type: "radio",
group_id: "rd",
},
{
item_id: "Button4",
name: "Test & Balance",
type: "radio",
group_id: "rd",
}
]
},
{
type: "ok_cancel",
ok_name: "Open"
},
]
}
};
commit:function (dialog) {
var results = dialog.store();
if (results["Button1"]) docType = 1;
else if (results["Button2"]) docType = 2;
else if (results["Button3"]) docType = 3;
else if (results["Button4"]) docType = 4;
}
app.execDialog(Dlg);
if(docType==1){
app.openDoc("/IOM/IOM.pdf", this);
}
else if(docType==2){
app.openDoc("/Submittal/Submittal.pdf", this);
}
else if(docType==3){
app.openDoc("/Owners Manual/Owners Manual.pdf", this);
}
else if(docType==4){
app.openDoc("/T&B/T&B.pdf", this);
}
Copy link to clipboard
Copied
The item_id must be a unique 4-character string.
On Wed, Mar 30, 2016 at 9:42 PM, jmarshallinc <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Changed all ID's to 4 characters but still nothing. Not getting any errors either.
var docType
var Dlg ={
description:
{
name: "Select File To Open",
elements:
[
{
type: "view",
elements:
[
{
item_id: "Hdr1",
name: "Select Document To Open",
type: "static_text",
},
{
item_id: "Btn1",
name: "IOM",
type: "radio",
group_id: "rdgp",
},
{
item_id: "Btn2",
name: "Submittal",
type: "radio",
group_id: "rdgp",
},
{
item_id: "Btn3",
name: "Owner's Manual",
type: "radio",
group_id: "rdgp",
},
{
item_id: "Btn4",
name: "Test & Balance",
type: "radio",
group_id: "rdgp",
}
]
},
{
type: "ok_cancel",
ok_name: "Open"
},
]
}
};
commit:function (dialog) { // called when OK pressed
var results = dialog.store();
if (results["Btn1"]) docType = 1;
else if (results["Btn2"]) docType = 2;
else if (results["Btn3"]) docType = 3;
else if (results["Btn4"]) docType = 4;
}
app.execDialog(Dlg);
if(docType==1){
app.openDoc("/IOM/IOM.pdf", this);
}
else if(docType==2){
app.openDoc("/Submittal/Submittal.pdf", this);
}
else if(docType==3){
app.openDoc("/Owners Manual/Owners Manual.pdf", this);
}
else if(docType==4){
app.openDoc("/T&B/T&B.pdf", this);
}
Copy link to clipboard
Copied
For some reason you placed the commit function outside of the dialog
object... Move it inside and it will work.
On Wed, Mar 30, 2016 at 9:58 PM, jmarshallinc <forums_noreply@adobe.com>
Copy link to clipboard
Copied
You were right! I'm very new to javascript. It fires now but I get this error.
NotAllowedError: Security settings prevent access to this property or method.
App.openDoc:62:Field Button7:Mouse Up
Copy link to clipboard
Copied
That means the file-paths you're specifying are not correct.
Copy link to clipboard
Copied
It actually appears to be a security issue. May not be able to get past it. I appreciate all your help.
Copy link to clipboard
Copied
Never mind, it was the path. I had a leading forward slash that wasn't needed. Works great now! Thanks again try67
Copy link to clipboard
Copied
Hey there, I saw your post and I too was trying my best to get it to work. I'm also a novice when it comes to javascript but I enjoy learning how to apply it. Would you mind sharing your results. I, for the life of me, cannot get it to work and I would like to see it working? Kindly, let me know. Thanks.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more