我正在处理具有多个输入的复杂synamic表单。我认为在服务器端构建并在客户端注入HTML服务表单可能更容易。我有:
function buildOptionList(id, options) {
// http://jsfiddle.net/4pwvg/
var document = '<div id="myDiv">Append here</div>';
// var myDiv = document.getElementById("myDiv");
//Create array of options to be added
// var array = ["Volvo","Saab","Mercades","Audi"];
var array = options;
//Create and append select list
var selectList = document.createElement("select");
selectList.setAttribute("id", id);
// myDiv.appendChild(selectList);
//Create and append the options
for (var i = 0; i < array.length; i++) {
var option = document.createElement("option");
option.setAttribute("value", array[i]);
option.text = array[i];
selectList.appendChild(option);
}
Logger.log(selectList)
return selectList;
}
但是当我跑步时,我得到了:
TypeError: Cannot find function createElement in object <div id="myDiv">Append here</div>
所以我想知道服务器端GAS是否有能力构建HTML?