Reputation: 805
Using Google AppScript. How could I find the checked RadioButton in a group? If it requires handler then with server one.
Many Thanks
Upvotes: 0
Views: 914
Reputation: 46802
there is an open issue on this but there is also a nice workaround ;-) (found by Romain Vialard, GAS TC)
here is a slightly modified version of his script adapted to run on a spreadsheet :
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;
}
Note that the radioValue item can be either a textbox or a hidden text, both possibilities are in the script/
Upvotes: 2