Action to happen depending on selection in dialog box
Hi, I am still very much a js novice.
I have managed to create a dialog box with my choices using the code given here https://community.adobe.com/t5/acrobat/i-need-to-create-a-custom-dialog-box-containing-check-boxes/m-p/8950855?page=1 by George Johnson. The code I have used follows below.
I am at a loss, however, as to how I get the selection to execute.
If the selection is Rad1 and the user clicks OK, then field "OC 1" must have the value of field "GP Loc 1" (I know how to do this :this.getField("OC 1").value = this.getField("GP Loc 1").value 😉 but where do I put this?
I the selection is Rad2 then the focus must move to "OC 1" (this.getField("OC 1").setFocus) but again where do I put this?
My modified code is:
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
var DocPrefs =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strGRP1:"",
bChk1:false,
GetRadioSel:function(oRslts,aCtrls){
for(var strRtn=aCtrls[0];aCtrls.length>0;strRtn=aCtrls.pop()){
if(oRslts[strRtn] == true)
return strRtn;
}
return "";
},
initialize: function(dialog)
{
var dlgInit =
{
"Chk1": this.bChk1,
};
dlgInit[this.strGRP1] = true;
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.strGRP1 = this.GetRadioSel(oRslt,["Rad1","Rad2"]);
//this.bChk1 = oRslt["Chk1"];
},
description:
{
name: "Input preferences",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Please select input method",
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "cluster",
item_id: "cls1",
name: "Form Target",
char_width: 8,
char_height: 8,
elements:
[
{
type: "radio",
item_id: "Rad1",
group_id: "GRP1",
name: "Use detail captured under general location (and amend if neccessary)",
},
{
type: "radio",
item_id: "Rad2",
group_id: "GRP1",
name: "Capture new information",
},
]
},
]
},
{
type: "ok_cancel",
},
]
},
]
}
};
// Example Code
DocPrefs.strGRP1 = "";
DocPrefs.bChk1 = false;
if("ok" == DocPrefs.DoDialog())
{
console.println("GRP1:" + DocPrefs.strGRP1);
console.println("Chk1:" + DocPrefs.bChk1);
}
Thanks
Raymond
