Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 弹出式消息框_Google Apps Script - Fatal编程技术网

Google apps script 弹出式消息框

Google apps script 弹出式消息框,google-apps-script,Google Apps Script,我有一个疑问, 我为提交表单制作了一个按钮,当我按下第一个按钮时,我会看到一条确认消息,确认是否继续,但当我按下“否”时,消息消失并返回表单,但第一个按钮不再起作用 你知道我错了。 谢谢大家 function doGet(){ var app = UiApp.createApplication().setTitle('Request Form'); var flow = app.createFlowPanel().setStyleAttribute("textAlign", "cente

我有一个疑问, 我为提交表单制作了一个按钮,当我按下第一个按钮时,我会看到一条确认消息,确认是否继续,但当我按下“否”时,消息消失并返回表单,但第一个按钮不再起作用

你知道我错了。 谢谢大家

function doGet(){
  var app = UiApp.createApplication().setTitle('Request Form');
  var flow = app.createFlowPanel().setStyleAttribute("textAlign", "center").setWidth("900px");  
  var buttons = app.createButton('Print and Save').setId('buttons');
  var handlers = app.createServerClickHandler('question').addCallbackElement(flow);
  buttons.addClickHandler(handlers);    
   flow.add(buttons);       
  app.add(flow);  
return app; 

}

function question(e){
var app = UiApp.getActiveApplication();    
var dialog = app.createPopupPanel().setModal(true).setSize(700, 100).setPopupPosition(10, 400);
var closeHandler = app.createClientHandler().forTargets(dialog).setVisible(false);
var handlersend = app.createServerClickHandler('Send');  
var handleract =app.createServerClickHandler('activateAgain');

var labelp  = app.createLabel('Are you sure that this information is correct?')
var buttonp1= app.createButton('yes, continue').addClickHandler(closeHandler).addClickHandler(handlersend);
var buttonp2= app.createButton('No, I want correct').addClickHandler(closeHandler).addClickHandler(handleract);
app.getElementById('buttons').setEnabled(false);

var gridp = app.createGrid(1,5);
        gridp.setWidget(0, 0, labelp)
      .setWidget(0,1,buttonp1)
      .setWidget(0,2,buttonp2);

dialog.add(gridp)
dialog.show();     
return app; 
}

function activateAgain(e){ 
var app = UiApp.getActiveApplication();   
app.getElementById('buttons').setEnabled(true);
return app;
}

function Send(e){
}

您正试图在clientHandler中实现这一点,这基本上是一个好主意,但问题是有些方法在clientHandler中不可用,例如
hide()
不可用

因此,您使用了
setVisible(false)
来隐藏对话框,但是您无法轻松地使其再次可见

总之,我发现使用
serverHandler
和一些修改会更容易

由于您似乎对UiApp非常熟悉,我不需要进一步解释,代码已经足够自解释了(我希望:-)

代码如下:()

function doGet(){
  var app = UiApp.createApplication().setTitle('Request Form');
  var flow = app.createFlowPanel().setStyleAttribute("textAlign", "center").setWidth("900px");  
  var buttons = app.createButton('Print and Save').setId('buttons');
  var handlers = app.createServerClickHandler('question').addCallbackElement(flow);
  buttons.addClickHandler(handlers);    
   flow.add(buttons);       
  app.add(flow);  
return app; 

}

function question(e){
  var app = UiApp.getActiveApplication();    
  var dialog = app.createPopupPanel().setModal(true).setSize(700, 100).setPopupPosition(10, 400).setId('dialog');
  var button = app.getElementById('buttons').setEnabled(true);
  var closeHandler = app.createClientHandler().forTargets(button).setEnabled(true);
  var correctHandler = app.createServerHandler('hideDialog');
  var handlersend = app.createServerClickHandler('Send');    
  var labelp  = app.createLabel('Are you sure that this information is correct?')
  var buttonp1= app.createButton('yes, continue').addClickHandler(handlersend);
  var buttonp2= app.createButton('No, I want correct').addClickHandler(closeHandler).addClickHandler(correctHandler);
  app.getElementById('buttons').setEnabled(false);

  var gridp = app.createGrid(1,5);
  gridp.setWidget(0, 0, labelp)
      .setWidget(0,1,buttonp1)
  .setWidget(0,2,buttonp2);

  dialog.add(gridp)
  dialog.show();     
  return app; 
}

function hideDialog(){
  var app = UiApp.getActiveApplication();    
  var dialog = app.getElementById('dialog');
  dialog.hide();
  return app;
}

function Send(e){
  var app = UiApp.getActiveApplication();    
  var dialog = app.getElementById('dialog');
  dialog.hide();
  app.getElementById('buttons').setEnabled(false);
  app.add(app.createLabel('send'));
  return app;
}