title: Capture user's click: InDesign scripting
body: <p>I'm trying to come up with a script that presents the user with a simple dialog box with three options: "Yes", "No" and "Cancel". Based on the user's input the script then produces two different kinds of pdfs (Special Report / Online PDF) or exits the process (in case they clicked "Cancel"). This is what I've come up with so far. Although I'm able to capture the user's click, I can't get the right script to run based on the user's choice:</p>
  
  <pre><code>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()
  </code></pre>