javascript - Accessing HTML service form object -


enter image description here

i'm working through https://developers.google.com/apps-script/guides/html/communication trying submit form info loaded google sheet. on client side have (based heavily on form example in article) :

<!doctype html> <html> <head>     <base target="_top">     <script>         // prevent forms submitting.         function preventformsubmit() {           var forms = document.queryselectorall('form');           (var = 0; < forms.length; i++) {             forms[i].addeventlistener('submit', function(event) {               event.preventdefault();             });           }         }         //      window.addeventlistener('load', preventformsubmit);          function handleformsubmit(formobject) {           google.script.run.withsuccesshandler(updateurl).processform(formobject);         }         //      function updateurl(url) {         //        var div = document.getelementbyid('output');         //        div.innerhtml = '<a href="' + url + '">got it!</a>';         //      }     </script> </head> <body>     <form id="myform" onsubmit="handleformsubmit(this)">         <div>             <select id="optionlist" name="email">                 <option>loading...</option>             </select>         </div>         <br>         <div>             <textarea name="message" rows="10" cols="30">             cat playing in garden.             </textarea>          </div>         <input type="submit" value="submit" />     </form> 

on server side (code.gs) have:

function processform(formobject) {    logger.log('in here');   var formblob = formobject.myfile;   var drivefile = driveapp.createfile(formblob);  return drivefile.geturl(); } 

i can see submit working because see 'in here' in logs. how can access form fields within processform function?

this chunk doesn't make sense me

  var formblob = formobject.myfile; 

your form doesn't contain input 'name' attribute set 'myfile'. once click 'submit', 'formobject' variable be:

{  email: "loading...", //from <select id="optionlist" name="email">  message: "the cat playing in garden." //from  <textarea name="message">  } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -