How to limit OK with a check box
i new javascript. have search web. have been working on box 3 days. have slapped various code example far cant seem accomplish needed last step.
i need check box limit ok button. aka "confirm" whether need second alert or other step unsure if don't check box option want available them cancel button. please help. if see suggest novice mistake please point out.
var meth0d = {
initialize: function(dialog) { // set default value radio button field
dialog.load({"rd01": true });
this.haspick = false; // disable radio button field
dialog.enable({
"rd01" : this.haspick,
"rd02" : this.haspick,
"rd03" : this.haspick });
},
commit:function (dialog) { // called when ok pressed
var results = dialog.store();
if (results["rd01"]) meth0d = "rolled";
else if (results["rd02"]) meth0d = "points";
else if (results["rd03"]) meth0d = "manual";
},
ckbx: function (dialog) { // process checkbox, verify method
this.haspick = !this.haspick;
dialog.enable({
"rd01" : this.haspick,
"rd02" : this.haspick,
"rd03" : this.haspick });
},
description:
{
name: "ability stat method",
elements:
[
{
type: "view",
align_children: "align_left",
elements:
[
{
type: "static_text",
name: "this form has 3 methods of determining ability stat rolls. \n\n roll = computer generated random roll in accordance phb. \n points = non-random method provides balance between players.\n manual = allows type in number between 3 18 \n\n note: roll method tracks how many times form has been opened or\n reset each day , how many reroll attempts player has made.",
bold: true,
font: "dialog",
char_width: 30,
height: 140
},
{
type: "check_box",
item_id: "ckbx",
name: "i understand."
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "methods: "
},
{
type: "radio",
item_id: "rd01",
group_id: "rado",
name: "rolled"
},
{
type: "radio",
item_id: "rd02",
group_id: "rado",
name: "points",
},
{
type: "radio",
item_id: "rd03",
group_id: "rado",
name: "manual",
}
]
}
]
},
{
type: "gap", //add small vertical gap between
height: 10 //..radio fields , buttons
},
{
type: "static_text",
name: "note: once click confirm have reset form access menu again.",
bold: false,
font: "dialog",
char_width: 30,
height: 20
},
{
type: "ok_cancel",
ok_name: "confirm",
cancel_name: "cancel",
}
]
}
};
var retn = app.execdialog(meth0d);
you need use validate function of dialog object. returns boolean (true/false) specifies whether dialog needs closed or not (the user can still cancel out of dialog, of course). in case this:
validate: function (dialog) {
var results = dialog.store();
if (!results["ckbx"]) {
app.alert("you must tick \"i understand\" box.");
return false;
}
return true;
},
More discussions in JavaScript
adobe
Comments
Post a Comment