2017-08-12 123 views

回答

0

表單提交不工作

我在你的HTML進行了一些修改。我認爲這樣做更簡單。而且我將表格更改爲活動表格,因爲這對我來說更容易。

Code.gs

function onOpen(){ 

var ui = SpreadsheetApp.getUi(); 

ui.showSidebar(HtmlService.createHtmlOutputFromFile('hissidebar') 
    .setTitle('My Form')); 

} 


function logFormObject(form){ 

Logger.log(form); 
var ss = SpreadsheetApp.getActiveSpreadsheet(); 
var sheet = ss.getActiveSheet();//changed this 
sheet.appendRow([form.name, form.lastName, form.age]); 


} 

sidebar.html

<!DOCTYPE html> 
<html> 
    <head> 
    </head> 
    <body> 
    <form id="myForm"> 

     Name <br> 
     <input name="name" /> <br> 
     Last Name: <br> 
     <input name="lastName" /> <br> 
     Age: <br> 
     <input name="age" /> <br> 

     <input type="submit" value="send" onClick="google.script.run.logFormObject(this.form)"> 

    </form> 
    </body> 
</html>