Variable Google Script for Htmlservice template

Asked

Viewed 53 times

0

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

To be clear, there are two charts that I would like to be able to make the choice of just one view when choosing what I wish. So far I can only choose to view one 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();
}
  • 1

    Your question is not very clear.

  • There are two graphs, I would like to choose an alternative view. Observing the code it is possible to identify two createTemplateFromFile which shows the need to try to switch between two html pages.

  • Could someone help...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.