我有一个从HTML文件填充的Google SideBar。这有一个按钮,当按下该按钮时,将一些值从表单传递到Google Apps脚本,然后在将数据传递到Google表格之前处理这些数据。
一切正常,除了一件事:
我创建的幻灯片栏没有传递该值以及所有其他方面。
任何人都可以解释原因吗?
我有大量的代码,因此您将看到的只是相关的减少所需数量。
<form id="form1">
<br>
<table width="100%">
<tr>
<td><p>Action Description: </p></td>
<td colspan="3"> <textarea id="description" name="description" rows="15" cols="22" required> </textarea> </td>
</tr>
<tr>
<td><p>Current Completion Percentage: </p></td>
<td>
<input type="range" min="0" max="100" value="0" id="percent" step="10" onchange="outputUpdate(value)" list="perstep">
<datalist id="perstep">
<option>0</option>
<option>10</option>
<option>20</option>
<option>30</option>
<option>40</option>
<option>50</option>
<option>60</option>
<option>70</option>
<option>80</option>
<option>90</option>
<option>1000</option>
</datalist>
</td>
<td>
<p><output for="form1" id="level">0</output>%</p>
</td>
</tr>
<tr>
<td><p>Assigned To: </p></td>
<td colspan="3"> <input id="assignedto" name="assignedto" type="text" required /> </td>
</tr>
<tr>
<td><p>Action Number: </p></td>
<td colspan="3"> <input id="actionnum" name="actionnum" type="number" /> </td>
</tr>
</table>
<br>
<hr>
<table width="100%">
<tr>
<td align="center" colspan="3" height="40">
<input id="date" name="date" type="date" required />
<br>
</td>
</tr>
<tr>
<td>
<input onclick="formSubmit()" type="button" value="Submit" />
</td>
<td>
<input onclick="google.script.host.close()" type="button" value="Close" /><br>
</td>
<td>
<input onclick="clearAll()" type="button" value="Clear All" name="clear" /><br>
</td>
</tr>
</table>
</form>
function getValuesFromForm(form1){
var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getSheetByName('Action Plan'),
sheet2 = ss.getSheetByName('Problem Details'),
description = form1.description,
percent = form1.percent,
assignedto = form1.assignedto,
actionnum = form1.actionnum,
date = form1.date,
oldNum = sheet2.getRange(11, 1).getValue(),
today1 = Utilities.formatDate(new Date(),"GMT","dd/MM/yyyy"),
lastCol = sheet.getLastColumn(),
lastRow = sheet.getLastRow(),
datecheck = sheet.getRange(1,lastCol).getValue();
if(description == "" || assignedto == "" || date == ""){
SpreadsheetApp.getUi().alert('Please ensure you have completed the minimal required fields');
} else {
if(datecheck == Utilities.formatDate(new Date(),"GMT","dd/MM/yyyy")) {
sheet.appendRow([oldNum +1, description, percent + " %", assignedto,date]);
sheet.getRange(lastRow +1,lastCol).setValue("New Action");
var head = sheet.getRange(1,1,1,lastCol);
head.setBackground("#b4a7d6");
head.setFontColor("white");
head.setFontWeight("bold");
head.setFontSize(12);
sheet2.getRange(11, 1).setValue(oldNum + 1);
} else {
sheet.getRange(1,lastCol + 1).setValue(today1);
sheet.appendRow([oldNum +1, description, percent + " %", assignedto,date]);
sheet.getRange(lastRow +1,lastCol +1).setValue("New Action");
var head = sheet.getRange(1,1,1,lastCol + 1);
head.setBackground("#b4a7d6");
head.setFontColor("white");
head.setFontWeight("bold");
head.setFontSize(12);
sheet2.getRange(11, 1).setValue(oldNum + 1);
}
}
}
目前我得到的只是&#34;未指定&#34;。
任何帮助将不胜感激。
答案 0 :(得分:1)
创建幻灯片栏的元素<input type="range" min="0" max="100" value="0" id="percent" step="10" onchange="outputUpdate(value)" list="perstep">
缺少name
属性,因此它永远不会对提交的数据做出任何贡献。因此,请添加具有合适值的name
属性。