Instantly share code, notes, and snippets.

What would you like to do?
GoogleAppsScriptでチェックボックス の改造
// global にしておく
var checkBoxArray = ['幼少期(0~6歳頃)',
function doGet() {
var app = UiApp.createApplication();
var checkboxpanel = app.createVerticalPanel();
var handler = app.createServerHandler('checkChanged').addCallbackElement(checkboxpanel);
var checkboxContainer = app.createVerticalPanel();
var infobox = app.createVerticalPanel();
for (var i=0; i < checkBoxArray.length; i++) {
checkboxContainer.add(app.createCheckBox(checkBoxArray[i]).setName("age" + i).addClickHandler(handler));
infobox.add(app.createLabel(checkBoxArray[i]).setId('info' + i).setVisible(false));
return app;
function checkChanged(e){
var app = UiApp.getActiveApplication();
for (var i=0; i < checkBoxArray.length; i++) {
// 飛んできたパラメータが"true"かどうかで表示非表示の切替
app.getElementById("info" + i).setVisible(e.parameter["age" + i] === 'true');
return app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment