2013-10-11 30 views
1

https://developers.google.com/apps-script/guides/html/communication該示例表明您應該在按鈕onclick中通過'this.parent'引用表單。如何最好的應該如果按鈕沒有直接的形式(可能是幾個div的深?this.parentNode.parentNode下等作品,但更明確的參考會更好地滿足我的表格來引用。如何參考表單提交文件上傳按鈕

<form id="myForm"> 
    <input name="myFile" type="file" /> 
    <input type="button" value="Submit" 
     onclick="google.script.run 
      .withSuccessHandler(updateUrl) 
      .processForm(this.parentNode)" /> 
</form> 
<div id="output"></div> 
+0

爲什麼不使用document.getElementById()? –

回答

1

我猜在你的情況下可能會使用:

onclick="google.script.run 
     .withSuccessHandler(updateUrl) 
     .processForm(document.getElementById('formId')"