gpt4 book ai didi

javascript - 用户输入的 If 语句放置(带有 code.gs、page.html、page-css.html、page-js.html 的谷歌应用程序脚本)

转载 作者:太空宇宙 更新时间:2023-11-04 06:07:56 29 4
gpt4 key购买 nike

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

我已经尝试在不同的地方多次放置“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);

最佳答案

我正在尝试回答这样一个令人困惑的问题,但这是我的尝试。

userInfo对象中添加一个team属性,用if语句填充,追加时添加到sheet中。

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);
...

关于javascript - 用户输入的 If 语句放置(带有 code.gs、page.html、page-css.html、page-js.html 的谷歌应用程序脚本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56673589/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com