Copy link to clipboard
Copied
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... 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
The checkbox has been removed from this code, so you can also remove all references to it.
To figure out what you need to do next you'll need to use the Console window. Notice that the code displays the result of the selection in the console. This is the value that will be used to decide the which field will be given focus.
You'll find a tutorial on the Console Window here:
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
Copy link to clipboard
Copied
At the same place where you use console.println.
Copy link to clipboard
Copied
The checkbox has been removed from this code, so you can also remove all references to it.
To figure out what you need to do next you'll need to use the Console window. Notice that the code displays the result of the selection in the console. This is the value that will be used to decide the which field will be given focus.
You'll find a tutorial on the Console Window here:
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
Copy link to clipboard
Copied
Thanks to all for your help. I managed to get it right.
I replaced
console.println("GRP1:" + DocPrefs.strGRP1);
with
{
if(DocPrefs.strGRP1="Rad1")
{this.getField("OC 1").value = this.getField("GP Loc 1").value
}