gpt4 book ai didi

javascript - 根据单选选择返回单元格值

转载 作者:行者123 更新时间:2023-12-03 07:30:57 24 4
gpt4 key购买 nike

我试图实现的目标是根据表单单选选择检索单元格值并更新文本区域。

进程:用户打开对话框。他们选择一个现场办事处。 Onclick 运行功能检查。检查后运行 google.script.run.withSuccessHandler(addSignatureLine).getSignatureLine(cellElement);应该运行并更新带有 ID 'AdditionalMessage' 的文本区域以及从 .getSignatureLine 检索到的签名行。

下面是html代码的两个功能:

<script>
function addSignatureLine(signatureLine){
document.getElementById('AdditionalMessage').value = '\n\n'signatureLine;
};

function updateSignatureLine() {
var cellElement = document.getElementById('ET');
console.log('cellElement: ' + cellElement);

google.script.run.withSuccessHandler(addSignatureLine)
.getSignatureLine(cellElement);
};

function check() {
var ele = document.getElementsByName('fieldOfficeET');
var flag = 0;

for (var i = 0; i < ele.length; i++) {
if (ele[i].checked)
flag = 1;

}
if (flag == 1)
document.getElementById('Submit').disabled = false;

};
</script>

这是 getSignatureLine.gs 脚本

function getSignatureLine(cellObject) {
var ss = SpreadsheetApp.openById('googleSheetId');
var sheet = ss.getSheetByName('AMS Contact Information');
var firstRow = 2;
var lastRow = 10;
var dataRange = sheet.getRange(firstRow, 1, lastRow, 11);
var dataValues = dataRange.getValues();

for (var key in cellObject) { //Loop through all the data in the form
Logger.log('key: ' + key);
Logger.log('value: ' + cellObject[key]);
}

//Determines the row the Field Office is in
for (var rr = 0; rr < dataValues.length; rr++) {
if (dataValues[rr][0] == cellObject.fieldOfficeET) {
var r = rr + 2
break;
}
}

var signatureLine = sheet.getRange(r, 11).getValue();
Logger.log("signatureLine: " + signatureLine)
return signatureLine;
}

最佳答案

此行有问题:

document.getElementById('AdditionalMessage').value = '\n\n'signatureLine;

我会尝试:

document.getElementById('AdditionalMessage').value = '\n\n' + signatureLine;

添加加号以连接文本。

关于javascript - 根据单选选择返回单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35801813/

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