Google App Maker - Add a button for timestamp collection in the onclick method

后端 未结 2 1607
我在风中等你
我在风中等你 2021-01-28 01:49

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 o

2条回答
  •  悲哀的现实
    2021-01-28 02:11

    Based on your comment:

    You got almost everything right with a couple of exceptions. So your getTimeStamp function should look like this:

    function getTimeStamp(){
        var timestamp = + new Date();
        return timestamp;
    }
    

    That is, because you have to return a value. The other problem is that when you are assigning the value to the datasource item, you don't have to use the keyword new; therefore, it should be like this:

    var timestamp = getTimeStamp();
    widget.datasource.item.Timestamp_IN = timestamp;
    

    The above is basic javascript. I recommend you to dig into javascript before moving forward with appmaker.

提交回复
热议问题