2017-07-27 6 views
2

フォームからデータを取得してタイトルとして入力する方法を教えてもらえますか?私はすでにGoogle Scriptのドキュメントを見てきましたが、これまで私は私に答えたり、私に似たような例を見せてくれるものは見つかりませんでした。今まで私は関連する科目とコードを見つけましたが、私の必要性には合っていませんでした。ここでフォームhtml google scrip

function doGet() { 
 
    return HtmlService 
 
     .createHtmlOutputFromFile('index') 
 
} 
 
function criarDocument(){ 
 
    
 
    var doc = DocumentApp.create('Doc'); 
 
} 
 
function criarSheet(){ 
 
     
 
    var sheet = SpreadsheetApp.create('Sheet'); 
 
} 
 
function createPresentation() { 
 
    var presentation = 
 
     Slides.Presentations.create({"title": "Presentation"}); 
 
    Logger.log("Created presentation with ID: " + presentation.presentationId); 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
    <head> 
 
     <meta charset="UTF-8"> 
 
     <style> 
 
     body{ 
 
      background-color: lightblue; 
 
     } 
 
     </style> 
 
     <link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css"> 
 
     <title>CRIE</title> 
 
     <script> 
 
      function criarDocument(){ 
 
       google.script.run.criarDocument(); 
 
       } 
 
      function criarSheet(){ 
 
       google.script.run.criarSheet(); 
 
      } 
 
      function createPresentation(){ 
 
       google.script.run.createPresentation(); 
 
      } 
 
     
 
      function titulo(){ 
 
       var st = document.getElementById('student').value; 
 
       var te = document.getElementById('teacher').value; 
 
       var wo = document.getelementById('work').value; 
 
      
 
       document.getElementById('student' + 'teacher' + 'work').value; 
 
     } 
 
     </script> 
 
    </head> 
 
    <body> 
 
    <h1><p align = "center">CRIE SEU ARQUIVO</p></h1> 
 
    <div> 
 
     <form id = 'form' onsubmit="titulo"> 
 
     <h2><p align = "center"> Student:</p></h2><p align = "center"> 
 
     <input type="text" name="estudante" id="student"> 
 
     <h2><p align = "center">Teacher: </p></h2><p align = "center"> 
 
     <input type="text" name="professor" id="teacher"> 
 
     <h2><p align = "center">Work Name</p></h2><p align = "center"> 
 
     <input type="text" name="trabalho" id="work"> 
 
     <br><br> 
 
     <button class="action" value="Submit" onclick= 'criarDocument()'>Start Document </button> 
 
     <button class="action" value="Submit" onclick='criarSheet()'>Start Sheet</button> 
 
     <button class="action" value="Submit" onclick='createPresentation()'>Start Presentation</button> 
 
     </form> 
 
    </div> 
 
    </body> 
 
</html>

答えて

1

は、サイドバーからスプレッドシートにタイムスタンプ、テキスト入力の簡単な例です。ノートに名前を付けることを忘れないでください。

Code.gs

function onOpen() 
{ 
    loadSideBar(); 
    SpreadsheetApp.getUi().createMenu('My Menu').addItem('loadSidebar', 'loadSideBar').addToUi(); 
} 

function dispText(txt) 
{ 
    var ss=SpreadsheetApp.getActiveSpreadsheet(); 
    var sht=ss.getSheetByName('Notes'); 
    var ts=Utilities.formatDate(new Date(), 'GMT-6', "M/dd/yyyy HH:mm:ss"); 
    var row=[]; 
    row.push(ts); 
    row.push(txt); 
    sht.appendRow(row); 
    return true; 
} 

function loadSideBar() 
{ 
    var userInterface=HtmlService.createHtmlOutputFromFile('sidebar'); 
    SpreadsheetApp.getUi().showSidebar(userInterface); 
} 

sidebar.html

<!DOCTYPE html> 
<html> 
    <head> 
    <base target="_top"> 
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
    <script> 
    $(function() { 
     $('#txt1').val(''); 
     }); 
    function sendText() 
    { 
     var txt=$('#txt1').val(); 
     google.script.run 
     .withSuccessHandler(clearText) 
     .dispText(txt); 
    } 
    function clearText() 
    { 
     $('#txt1').val(''); 
    } 
    console.log("My code"); 
    </script> 
    </head> 
    <body> 
    <textarea id="txt1" rows="12" cols="35"></textarea><br /> 
    <input id="btn1" type="button" value="submit" onClick="sendText();" /> 

    </body> 
</html> 
+0

私を助けてくれてありがとう。 –

関連する問題