javascript - datalist selected value is "null" in the sheet
问题描述
I have a datalist problem : I have too much values in my datalist to use a simple select. I changed my html to use a datalist instead. The problem is that the selected value is "null" when i want to set it in the sheet. The values are like : "PDCTLEA1-N00C06" in "mesSwitchs" list.
<script>
function validerAd()
{
let idPort1a = document.getElementById("idPort1a").value;
google.script.run.nouvAdresse(idPort1a);
}
<form>
<p8>
<label for="idPort1a" id="labelPort1a">Choisissez un switch :</label>
<input list="idPort1a" name="idPort1a" id="idPort1aListe">
<datalist id="idPort1a">
<br/>
<? for (var i = 0; i < mesSwitchs.length; i++) { ?>
<option value="<?= mesSwitchs[i][0] ?>" ><?= mesSwitchs[i][0] ?></option>
<? } ?>
</datalist>
</p8>
function nouvAdresse(idPort1a)
{
AdressesIP.getRange(2,2).setValue(idPort1a);
}
In the sheet, it will set "null" instead of the selected value. Do you know why ?
解决方案
Only thing I can think is a typo. You're using idPort1a
everywhere.
But you're trying to paste idPort1
(without a
) in your function.
Probably your function should look like this:
function nouvAdresse(idPort1a)
{
AdressesIP.getRange(2,2).setValue(idPort1a); // <-- here
}
Just a guess.
推荐阅读
- r - 如何以闪亮的方式显示已拆分为不同部分的数据?
- javascript - 我如何使用 bootstrapvue 执行关键功能而不是使用长 html 代码?
- jira - 无法在 Jira DB 中链接 JIRAISSUE 和 CUSTOMFIELD 以在 Sprint、Sprint 开始日期、Sprint 结束日期、故事点中查找以下值
- javascript - 如何使用 vanilla Javascript 将画布元素旋转到鼠标位置?
- sql - 如何将一个表转换为另一个表结构并比较数据 | 甲骨文
- javascript - 为什么 javascript CDN 依赖项的加载速度比 python pip 或 javascript npm 依赖项要快得多?
- node.js - AWS Lambda 和 Fluent FFMPEG 错误“无法读取未定义的属性“isStream””
- javascript - 使用 DOM JavaScript 的新闻网格
- flutter - Flutter/dart 中点对点网络的最佳实践是什么?
- c# - Automapper 不适用于具有外键的模型