开发者

RadioButtons generation?

I am working on scripts that would generate a list of radiobuttons. The user would have to choose one of the answer, and one cell is filled with the result.

The number of radiobuttons in not known at the beginning, and depends onthe number of contacts in a group of gmail contacts.

My question is pretty simple, how can I display as much radiobuttons as needed ? I tried to put them in a loop, but it appears that nothing is loaded but my submit button.

function test(){
    var mydoc = SpreadsheetApp.getActiveSpreadsheet();
    var app = UiApp.createApplication().setTitle('Choose your contact'); 
    //to use radios 开发者_JAVA百科you will need a form  
    var form = app.createFormPanel().setId('form').setEncoding('multipart/form-data');

    //Retrieving contacts in first speadsheet tag
    var sheet = mydoc.getSheets()[0];//select first sheet
    var tagName = sheet.getRange("G4").getValue();//where the tag is placed
    var length = count_contacts_in_tag(tagName)

    //initiates grid
    var formContent = app.createGrid().resize(length + 1,1);
    form.add(formContent);

    var group = ContactsApp.getContactGroup(tagName);
    var contacts = group.getContacts();
    **// TODO: My problem is here!**
    for (var i in length) {
        var myRadio1 = app.createRadioButton("radio", "one").setFormValue('one');
        formContent.setWidget(i, 0, myRadio1);
    }

    formContent.setWidget(length, 0, app.createSubmitButton('Submit!')); //submit button
    app.add(form);

    mydoc.show(app); 
}

Any hint would be grately appreciated !

Thanks by advance


The answer is pretty straghtfoward, as long as you know where to search for the information. THe Google Scripts are a subset of JavaScript. My problem was simply coming from the structure of my loop.

It should be : for (var i=0; i

C U . . .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜