简体   繁体   English

Google Apps脚本Textarea

[英]Google Apps Script Textarea

I have the following basic code to attempt changing the value of the textarea element. 我有以下基本代码尝试更改textarea元素的值。 Using standard HTML works fine; 使用标准HTML效果很好; however, using Google Apps Script, it will not work. 但是,使用Google Apps脚本将无法使用。 There will be more to the program which will include additional lines via \\n so a standard input tag can't be used - this is just the basic piece in which I need to populate text within the element. 该程序将包含更多内容,其中将通过\\ n包含其他行,因此无法使用标准输入标签-这只是我需要在元素内填充文本的基本部分。 Does anyone know if this is possible with GAS? 有人知道GAS是否有可能? Note, only wanting to use the HTML file, not pure GAS JavaScript. 请注意,仅想使用HTML文件,而不是纯GAS JavaScript。

<!DOCTYPE html>
<base target="_top">
<button id=calc>test</button>
<textarea id=t></textarea>
<script>
document.getElementById("calc").onclick=function(){
document.getElementById("t").value="test";
}
</script>

looks like you forgot to put "calc" and "t" inside quatation marks like this - "id_of_an_element" 看起来您忘了像这样将“ calc”和“ t”放在引号中-“ id_of_an_element”

When I used Visual Code to check if it works in pure HTML it fixed it, but in Google Apps Script it didn't 当我使用Visual Code检查它是否可以在纯HTML中运行时,它对其进行了修复,但是在Google Apps脚本中却没有

I tested the below code in Google Apps Script and it works, I hope it helps 我在Google Apps脚本中测试了以下代码,并且可以正常运行,希望对您有所帮助

 <!DOCTYPE html> <html lang="en"> <body> <base target="_top"> <button id="calc">test</button> <textarea id="t">my text area inital value</textarea> <script> document.getElementById("calc").onclick=function(){ document.getElementById("t").value="test"; } </script> </body> </html> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM