2012-06-17 19 views

回答

1

上有這樣的一個open issue,但也有一個很好的解決辦法;-)(羅曼Vialard,GAS TC發現)

這裏是他的劇本稍加修改的版本適用於在電子表格中運行:

function radiotest() { 
    var app = UiApp.createApplication(); 
    var panel = app.createVerticalPanel(); 
    var radioValue = app.createTextBox(); 
    radioValue.setId("radioValue").setName("radioValue");    
    // var radioValue = app.createHidden().setName("radioValue") ;// choose the one you like 
    for(var i = 1; i < 10; i++){ 
    var name = 'choice '+i; 
    var handler = app.createClientHandler().forTargets(radioValue).setText(name); 
    panel.add(app.createRadioButton('radioButtonGroup',name).addValueChangeHandler(handler)); 
    } 
    panel.add(radioValue); 
    var Valide=app.createButton("Valide").setId("val"); 
    panel.add(Valide)     
    app.add(panel); 
//    
    var handler = app.createServerHandler("valide"); // this is the server handler 
    handler.addCallbackElement(radioValue) 
    Valide.addClickHandler(handler); 
// 
    SpreadsheetApp.getActiveSpreadsheet().show(app);// show app 
    } 
    // 
function valide(e){ ;// This function is called when key "validate" is pressed 
    var sh = SpreadsheetApp.getActiveSheet(); 
    var RadioButton = e.parameter.radioValue;    
    sh.getRange('A1').setValue(RadioButton); 
    var app = UiApp.getActiveApplication(); 
    return app; 
}​ 

注意,radioValue項目可以是文本或隱藏文本,這兩種可能性都在腳本/

+0

中號任何感謝塞爾的代碼和公開問題的來源。 – Richi