简体   繁体   中英

.setValue of an Element/Hidden Element

function change(e){
var app = UiApp.getActiveApplication();  
app.getElementById("date").setValue(e.parameter.picker);  
Browser.msgBox(e.parameter.date+"|"+e.parameter.picker);  
return app;  
}

I've spent the last hour or so trying to figure out what I am doing wrong, but, the .setValue() seems to not be working, since the Browser.msgBox displays: " | August 8, 2012 0:00:00 (MST)" even though both sides from the | should display the same thing.

The right way to assign a value to a widget in a handler function in GAS is simply (just as you did in your question) like this :

app.getElementById("date").setValue(e.parameter.picker)

but what follows in your code can't work because value is passed to the e.parameter when the handler function is called , not during execution of the handler. This means that e is not updated inside the handler function but it will be on the next call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM