基于无线电选择返回小区值

时间:2016-03-04 17:01:01

标签: javascript html google-apps-script google-sheets

我想要实现的目标是根据表单无线电选择检索单元格值并更新文本区域。

处理:用户打开对话框。他们选择了一个办公室。 Onclick运行功能检查。检查后运行google.script.run.withSuccessHandler(addSignatureLine).getSignatureLine(cellElement);应该使用Id' AdditionalMessage'运行并更新textarea。使用从.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>
&#13;
&#13;
&#13;

这是getSignatureLine.gs脚本

&#13;
&#13;
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;
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

此行存在问题:

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

我会尝试:

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

添加加号以连接文本。