簡體   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