Google Script variable for HTMLService template

0

I have a published Google script . I would like to be able to select a display option between two alternatives based on the choice of password. I tried if else statement , switch , without success. See link and code for the two Google charts below:

To be clear, there are two graphs that I would like to be able to choose from just one view when choosing what I want. So far I can only choose to see an option.

function doGet(passed) {

    switch(passed.parameter.form) {
        case '1':
            return HtmlService.createTemplateFromFile('IndexY').evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
        break;
        case '2':
        default:
            return HtmlService.createTemplateFromFile('Index').evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
        return result;
    }
}

function onLogin(form) {
    if (form.username == "a") {
        var template =  HtmlService.createTemplateFromFile('Response');

        //Setup any variables that should be used in the page
        template.firstName = "Your name is here";
        template.username = form.username;

        return template.evaluate()
        .setSandboxMode(HtmlService.SandboxMode.IFRAME)
        .getContent();
    } 
    if (form.username == "b") {
        var templateb =  HtmlService.createTemplateFromFile('ResponseY');

        //Setup any variables that should be used in the page
        templateb.firstName = "Your name is here";
        templateb.username = form.username;

        return templateb.evaluate()
        .setSandboxMode(HtmlService.SandboxMode.IFRAME)
        .getContent();
    }
    else {
        throw "You could not be found in the database please try again.";
    }
}


function include(filename) {
    return HtmlService.createTemplateFromFile(filename)
    .evaluate()
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .getContent();
}
    
asked by anonymous 16.01.2017 / 20:09

0 answers