首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从showModalDialog返回数据

从showModalDialog返回数据
EN

Stack Overflow用户
提问于 2020-06-05 19:27:05
回答 1查看 50关注 0票数 1

我想继续在函数abfrage()中处理来自ModalDialog的数据。我想稍后在.It上创建一个具有多个输入字段的循环,所以我不会将其写在html页面上。

代码语言:javascript
复制
function abfrage(){
  let count = 1;
  let html = '<input type="text" name="text">';
  var t = HtmlService.createTemplateFromFile('dialogForm');
  let dialog = ui.showModalDialog(t.evaluate(), 'Hello');
}

dialogForm.html

代码语言:javascript
复制
<!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
      <h1>Userform</h1>
        <table>
        <?!= html ?>
        </table>
        <input type="button" value="Close" onclick="google.script.host.close()" >
        <input type="submit" value="Submit" class="action">
    </body>
    </html>
EN

回答 1

Stack Overflow用户

发布于 2020-06-05 23:11:08

gs:

代码语言:javascript
复制
function abfrage(){
  let count = 1;
  let html = '<form><br /><input type="text" name="text">';
  var t = HtmlService.createTemplateFromFile('dialogForm');
  let dialog = ui.showModalDialog(t.evaluate(), 'Hello');
}

function serversidefunctionname(obj) {
  var name=obj.name;
  //process name
  //return html if desired 
}

HTML:

代码语言:javascript
复制
<!DOCTYPE html>
    <html>
      <head>
        <base target="_top">
      </head>
      <body>
      <h1>Userform</h1>
        <?!= html ?>
        <br /><input type="button" value="Close" onclick="google.script.host.close()" >
        <br /><input type="button" value="Submit" class="action" onClick="processForm(this.parentNode);" /> 
      </form>
      <script>
        function processForm(obj) {
          google.script.run
          .withSuccessHandler(function(retobj){
            //process return from server side function if any
          })
          .serversidefunctionname(obj);
        }
      </script>
    </body>
    </html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62214281

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档