2013-05-29 15 views
1

我正在嘗試使用HTML服務,特別是HTML表單。 我在複雜的html結構中有我的sumbit按鈕。我可以如何抽取這條線:HTML服務和表單

<input type="button" value="Submit" 
      onclick="google.script.run 
       .withSuccessHandler(returnFunctionHandler) 
       .processForm(this.parentNode)" /> 

this.parentNode它不是Node的表格元素。

現在,沒有任何內容傳遞給ProcessForm應用程序腳本函數,它似乎根本沒有運行。

預先感謝您

<script> 
     function updateUrl(url) { 
     var div = document.getElementById('output'); 
     div.innerHTML = '<a href="' + url + '">Got it!</a>'; 
     } 
    </script> 
    <form id="myForm"> 
    <fieldset style="width: 0px; border-color: #0000FF;"> 
    <legend style="color: #0000FF; font-size: 12pt; font-weight: bold; width:400px">Inserimento richiesta</legend> 
    <table border="0"> 
    <tr> 
    <td style="font-weight: bold;">Data*:</td><td></td> 
    </tr> 
    <tr> 
    <td style="font-weight: bold;">Richiedente*:</td> 
    <td> 
    <select style="width:150px;"> 
    <? 
    var data=recuperaDati("idSSRichiedenti"); 
    for (var j = 1; j < data.length; j++) { 
    ?> 
    <option value <?=data[j][1]?>><?= data[j][0]?></option> 
    <? } 
    ?> 
    </select></td> 
    </tr> 
    <?//tipologia?> 
    <tr> 
    <td style="font-weight: bold;">Tipologia*:</td> 
    <td> 
    <select style="width:150px;"> 
    <? 
    var data=recuperaDati("idssTipologia"); 
    for (var j = 1; j < data.length; j++) { 
    ?> 
    <option value <?=data[j][0]?>><?= data[j][0]?></option> 
    <? } 
    ?> 
    </select></td> 
    </tr> 

    <?//livelli di urgenza?> 
    <tr> 
    <td style="font-weight: bold;">Livelli di urgenza*:</td> 
    <td> 
    <select style="width:150px;"> 
    <? 
    var data=recuperaDati("idssLivelliUrgenza"); 
    for (var j = 1; j < data.length; j++) { 
    ?> 
    <option value <?=data[j][0]?>><?= data[j][0]?></option> 
    <? } 
    ?> 
    </select style="width:150px;"></td> 
    </tr> 

    <?//Reparti?> 
    <tr> 
    <td style="font-weight: bold;">Reparto*:</td> 
    <td> 
    <select style="width:150px;"> 
    <? 
    var data=recuperaDati("idssReparti"); 
    for (var j = 1; j < data.length; j++) { 
    ?> 
    <option value <?=data[j][0]?>><?= data[j][0]?></option> 
    <? } 
    ?> 
    </select></td> 
    </tr> 


    <tr> 
    <tr> 
    <td style="font-weight: bold;">Cognome:</td><td><input type="text" name="cognome" size="10"></td> 
    </tr> 
    <tr> 
    <td style="font-weight: bold;">E-mail:</td><td><input type="text" name="email" size="10"></td> 
    </tr> 
    <tr> 
    <td style="font-weight: bold;">Allegati:</td><td><input name="myFile" type="file"/></td> 
    </tr> 
    <tr> 
    <td></td><td style="float:right;"> 
     <input type="button" value="Submit" 
      onclick="google.script.run 
       .withSuccessHandler(returnFunctionHandler) 
       .processForm(this.parentNode)" /></td> 
    </tr> 
    </table>  
    </fieldset> 
    </form> 
    <div id="output"></div> 

回答

0

您可以使用document.getElementById('myForm')檢索表單的元素。

所以:

<input type="button" value="Submit" 
      onclick="google.script.run 
       .withSuccessHandler(returnFunctionHandler) 
       .processForm(document.getElementById('myForm'))" /> 
+0

你好Davinov,我已經嘗試用這段代碼嘗試多次,但它不起作用。 –

0

您可以使用此:

<input type="button" value="Submit" 
      onclick="google.script.run 
       .withSuccessHandler(returnFunctionHandler) 
       .processForm(this.parentNode.parentNode 
       .parentNode.parentNode.parentNode)" /> 

(如果我只是計數的父母權數量最多的表單標籤)。

不是很高興看到和很難修改,但它在我只有兩個級別的類似情況下工作。雖然沒有測試你的代碼。

問候。