Google App Maker-在onclick方法中添加一个用于时间戳记收集的按钮 [英] Google App Maker - Add a button for timestamp collection in the onclick method
问题描述
我上下搜索,找不到适合的特定答案.我需要在App Maker中的表单中添加一个按钮,以记录单击时的时间戳记,而不是日期.到目前为止,我设法上班的唯一一件事就是
I searched high and low and cannot find a specific answer that works. I need to add a button to a form in App Maker to record a timestamp, not a date, when clicked. So far the only thing that I've managed to get to work is
widget.datasource.item.Timestamp_OUT = new Date();
我也尝试过
var timestamp = getTimeStamp();
但是继续出现错误"ReferenceError:"getTimeStamp"未定义".我可能会错过显而易见的东西,因为做这样简单的事情并不难.任何帮助表示赞赏,谢谢.
But keep getting an error "ReferenceError: "getTimeStamp" is not defined". I'm probably missing the obvious as it shouldn't be this difficult to do something this simple. Any help is appreciated, thanks.
推荐答案
成功!在这里的所有人和此链接的所有人的帮助下: Google网上论坛-解决方案我设法解决了这个问题(并在此过程中学到了一些东西).
Success! With the help of everyone here and the guys at this link: Google Groups - Solution I've managed to crack the case (and learn some stuff along the way).
如果您将"+"从函数中删除,则上面的所有内容都可以正常工作
Everything originally above works just fine if you take the " + " out of the function so it reads
function getTimeStamp(){
var timestamp = new Date();
return timestamp;
}
然后,点击
var timestamp = getTimeStamp();
widget.datasource.item.Timestamp_IN = timestamp;
接下来,使用以下格式格式化表格以显示正确的数据
Next, format the table to show the correct data with
@datasource.item.Test_Timestamp#formatDate('EEEE \x27at\x27 h:mm:ss a')
还有普雷斯托!"您将获得一个按钮,单击该按钮可为您提供一个时间戳.对参加会议的每个人都表示感谢,这就是学习的人继续这样做的原因,并且在遇到困难时也不会放弃:)
And "Hey Presto!" you get a button that, when clicked, gives you a timestamp. Thaks to everyone who pitched in, you're the reason people who are learning continue to do so and don't throw in the towel when things get difficult :)
这篇关于Google App Maker-在onclick方法中添加一个用于时间戳记收集的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!