我正在尝试编写一个脚本,该脚本向用户显示一个简单的对话框,其中包含三个选项:“是”、“否”和“取消”。根据用户的输入,脚本会生成两种不同类型的 pdf(特别报告/在线 PDF)或退出流程(如果他们单击“取消”)。到目前为止,这是我想出的。尽管我能够捕获用户的点击,但我无法根据用户的选择运行正确的脚本:
function checkReportType(){
//draw window
var askReportWindow = new Window("dialog", "Report Type");
askReportWindow.textmissing = askReportWindow.add('statictext{text:"Is this a Special Report?", justify:"center"}');
var myInputGroup = askReportWindow.add("group");
var myButtonGroup = askReportWindow.add("group");
myButtonGroup.alignment = "right";
//add buttons
var yesButton = myButtonGroup.add("button", undefined, "Yes");
var noButton= myButtonGroup.add("button", undefined, "No");
var cancelButton = myButtonGroup.add("button", undefined, "Cancel");
//setting values to false for "yes" and "no" buttons
var yesClicked = false;
var noClicked = false;
//change button value on click
yesButton.onClick = function(){
yesClicked = true;
//alert("k");
}
noButton.onClick = function(){
noClicked = true;
//alert("l");
}
//show window
askReportWindow.show();
//check for click
if(yesClicked===true){
exportSpecialReport();
}else if(noClicked===true){
exportOnlinePDF();
}else{
exit();
askReportWindow.destroy();
}
}//end checkReportType()