为什么我的表单中的值没有传递给 Google 代码?
Why is a value in my Form not being passed to the Google code?
我有一个从 HTML 文件填充的 Google 边栏。这有一个按钮,当按下该按钮时,会将一些值从表单传递到 Google Apps 脚本,然后在将数据传递给 Google Sheet.[=13= 之前处理数据]
除一件事外一切正常:
我创建的滑动条没有将值与所有其他方面一起传递。
谁能解释为什么?
我有大量的代码,所以您将看到的只是相关的削减所需数量。
HTML:
<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>
Google.gs代码:
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);
}
}
}
我现在得到的只是"unspecified"。
如有任何帮助,我们将不胜感激。
创建滑动条的元素 <input type="range" min="0" max="100" value="0" id="percent" step="10" onchange="outputUpdate(value)" list="perstep">
缺少 name
属性,因此它永远不会对提交的数据做出任何贡献。所以添加一个具有合适值的 name
属性。
我有一个从 HTML 文件填充的 Google 边栏。这有一个按钮,当按下该按钮时,会将一些值从表单传递到 Google Apps 脚本,然后在将数据传递给 Google Sheet.[=13= 之前处理数据]
除一件事外一切正常:
我创建的滑动条没有将值与所有其他方面一起传递。
谁能解释为什么?
我有大量的代码,所以您将看到的只是相关的削减所需数量。
HTML:
<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>
Google.gs代码:
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);
}
}
}
我现在得到的只是"unspecified"。
如有任何帮助,我们将不胜感激。
创建滑动条的元素 <input type="range" min="0" max="100" value="0" id="percent" step="10" onchange="outputUpdate(value)" list="perstep">
缺少 name
属性,因此它永远不会对提交的数据做出任何贡献。所以添加一个具有合适值的 name
属性。