繁体   English   中英

用户输入的语句放置位置(带有code.gs,page.html,page-css.html,page-js.html的Google Apps脚本)

[英]If statement placement for user input(google apps script with code.gs, page.html, page-css.html,page-js.html)

我正在创建一个Web应用程序,允许用户选择他们当前的部门,他们将被暂时借给的部门,正在执行的任务以及在该任务上花费的时间。 我需要写一些声明,根据他们当前部门的选择来确定他们所在的团队(当前或新)。

我在不同的地方尝试了多个“ if语句”的放置

//// code for appending new row into sheet need to add "team" as the second ////variable    
function userClicked(userInfo){
    ws.appendRow([user,userInfo.department,userInfo.tempDepartment,userInfo.task,userInfo.timeSpent,new Date()]);
}

//// function for selecting the varibales that get appended into worksheet
function doStuff() {
    var userInfo = {};

    userInfo.department = document.getElementById('department').value;
    userInfo.tempDepartment = document.getElementById('tempDepartment').value;
    userInfo.task = document.getElementById('task').value;
    userInfo.timeSpent = document.getElementById('timeSpent').value;

    google.script.run.userClicked(userInfo);

    document.getElementById('timeSpent').value='';
    var dpt = document.getElementById('department');
    dpt.selectedIndex=0;
    M.FormSelect.init(dpt);
    var tempDpt = document.getElementById('tempDepartment');
    tempDpt.selectedIndex=0;
    M.FormSelect.init(tempDpt);
    var task = document.getElementById('task');
    task.selectedIndex=0;
    M.FormSelect.init(task);

我正竭尽全力试图回答这样一个令人困惑的问题,但这是我的尝试。

team属性添加到userInfo对象,用if语句填充它,然后在添加时将其添加到工作表中。

function userClicked(userInfo){
    ws.appendRow([user,userInfo.department,userInfo.tempDepartment,userInfo.team,userInfo.task,userInfo.timeSpent,new Date()]);
}

//// function for selecting the varibales that get appended into worksheet
function doStuff() {
    var userInfo = {};

    userInfo.department = document.getElementById('department').value;
    userInfo.tempDepartment = document.getElementById('tempDepartment').value;
    userInfo.task = document.getElementById('task').value;
    userInfo.timeSpent = document.getElementById('timeSpent').value;
    if (userInfo.department == "Refill") {
        userInfo.team = "New";
    } else {
        userInfo.team = "Old";
    }

    google.script.run.userClicked(userInfo);
    ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM