2011-09-22 187 views
0

我有一个简单但有问题的问题。将参数传递给mouseCallback

有没有办法,使用谷歌脚本发送参数到mouseCallback? 这里解释一些例子,但每次在函数中写入单元格。

我希望这个单元格随时间变化,我需要传递一个字符串给回调函数。

这工作

function foo() { 
    var doc = SpreadsheetApp.getActiveSpreadsheet(); 
    var app = UiApp.createApplication(); 

    var button = app.createButton('submit'); 
    app.add(button); 

    var handler = app.createServerClickHandler('b'); 
    button.addClickHandler(handler); 

    doc.show(app); 
} 

function b() { 
    var doc = SpreadsheetApp.getActiveSpreadsheet(); 
    var cell = doc.getRange('a1'); 
    cell.setValue(Number(cell.getValue()) + 1); 

    var app = UiApp.getActiveApplication(); 
    app.close(); 
    // The following line is REQUIRED for the widget to actually close. 
    return app; 
} 

我想是这样的

function foo() { 
    var doc = SpreadsheetApp.getActiveSpreadsheet(); 
    var app = UiApp.createApplication(); 

    var button = app.createButton('submit'); 
    app.add(button); 

    var value = 'A1'; 
    var handler = app.createServerClickHandler('b', value); 
    button.addClickHandler(handler); 

    doc.show(app); 
} 

function b(value) { 
    var doc = SpreadsheetApp.getActiveSpreadsheet(); 
    var cell = doc.getRange(value); 
    cell.setValue(Number(cell.getValue()) + 1); 

    var app = UiApp.getActiveApplication(); 
    app.close(); 
    // The following line is REQUIRED for the widget to actually close. 
    return app; 
} 

谁能帮我在这?

谢谢!

回答