如何将HTML表单提交到工作表? [英] How to submit HTML form into a Sheet?

查看:136
本文介绍了如何将HTML表单提交到工作表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查过,而且我发现的大部分事情都是从2012年开始的,并且解决了当时存在的错误。不幸的是,我不太了解Google的文档。



我有一个脚本项目,它为网页上的HTML表单提供服务:

 < form id =gradingform> 
< input type =textname =nameplaceholder =Name>
< input type =numbername =gradeplaceholder100>
< input type =submitonclick =<这是我遇到的问题>>
< / form>

我相信这需要像其他时间在处理网页时获取脚本一样处理 - 通过使用 google.script.run 。对于一个特定的表单,我认为它应该使用成功处理程序,例如,沿着



google.script.run.withSuccessHandler(gradeSubmitted).recordGrades()



gradeSubmitted()将是一个函数,它只是简单地显示一条消息,通过做一些简单的div更改很容易。我真正的问题是什么 recordGrades()会是。



如何将表单传递给此函数,以及如何从表格中收集信息?从那里我将它添加到工作表中,一旦信息在数组中,这很容易,因为我可以将它追加。这些文件声称表单信息应该以 Blob 的形式传递,但Google的例子有点令人困惑。

解决方案

这就是你必须做的事情
$ b

onclick =google.script.run.withSuccessHandler(gradeSubmitted) .recordGrades(this.form)



而在code.gs文件中,您将收到一个json作为



[16-03-25 10:51:51:046 IST] {grade = 10,name = Anees}


I've checked around and most things I've found are from 2012 and workarounds for a then-existent bug. Unfortunately I'm not understanding Google's documentation on this very well.

I have a script project that is serving a web page to visitors with an HTML form:

<form id="gradingform">
<input type="text" name="name" placeholder="Name">
<input type="number" name="grade" placeholder"100">
<input type="submit" onclick="<this is where I'm having issues>">
</form>

I believe that this needs to be handled like any other time getting a script while serving a web page - by using the google.script.run. With a form specifically, I think that it's supposed to be using a success handler, so for example, something along the lines of

google.script.run.withSuccessHandler(gradeSubmitted).recordGrades()

gradeSubmitted() would be a function that just dispays a message, easy enough by doing some easy div changing. What my real issue is what recordGrades() would be like.

How do I pass the form to this function, and how do I collect the information from the form? From there I will be adding it to a Sheet, which is easy enough once the information is in an array because I can just append it. The documents say the form information should be passed as a Blob, but Google's example is kind of confusing.

解决方案

This is what you have to do

onclick="google.script.run.withSuccessHandler(gradeSubmitted).recordGrades(this.form)"

And in the code.gs file you will be receiving a json as

[16-03-25 10:51:51:046 IST] {grade=10, name=Anees}

这篇关于如何将HTML表单提交到工作表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆