title: google apps script: html - form submit, get input values
body: <p>I'm trying to use a sidebar with a form to get user input. The code is bound to a Google Sheets file.<br><br>
  Code.gs:</p>
  
  <pre><code>function onOpen() {
    SpreadsheetApp.getUi()
        .createMenu('Custom Menu')
        .addItem('Show sidebar', 'showSidebar')
        .addToUi();
  }
  
  function showSidebar() {
    var html = HtmlService.createHtmlOutputFromFile('Page')
        .setTitle('My custom sidebar')
        .setWidth(300);
    SpreadsheetApp.getUi()
        .showSidebar(html);
  }
  
  function processForm(formObject) {
    var ui = SpreadsheetApp.getUi();
    ui.alert("This should show the values submitted.");
  }
  </code></pre>
  
  <p>Page.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;base target="_top"&gt;
    &lt;/head&gt;
    &lt;body&gt;
      Please fill in the form below.&lt;br&gt;&lt;br&gt;
      &lt;form id="myForm" onsubmit="google.script.run.processForm(this)"&gt;
        First name:
        &lt;input type="text" name="firstname"&gt;&lt;br&gt;&lt;br&gt;
        Last name:
        &lt;input type="text" name="lastname"&gt;&lt;br&gt;&lt;br&gt;
        Gender:&lt;br&gt;
        &lt;input type="radio" name="gender" value="male" checked&gt; Male&lt;br&gt;
        &lt;input type="radio" name="gender" value="female"&gt; Female&lt;br&gt;
        &lt;input type="radio" name="gender" value="other"&gt; Other&lt;br&gt;
        &lt;br&gt;
        &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;&lt;br&gt;
      &lt;input type="button" value="Cancel" onclick="google.script.host.close()" /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I press "Submit", the alert opens with the given message and my browser opens to a url which shows a blank page
  (<a href="https://n-ms22tssp5ubsirhhfqrplmp6jt3yg2zmob5vdaq-0lu-script.googleusercontent.com/userCodeAppPanel?firstname=&amp;lastname=&amp;gender=male" rel="noreferrer">https://n-ms22tssp5ubsirhhfqrplmp6jt3yg2zmob5vdaq-0lu-script.googleusercontent.com/userCodeAppPanel?firstname=&amp;lastname=&amp;gender=male</a>).
  I'd like the alert to display the values submitted, and I don't want the extra page to open. <br><br>
  Pretty simple problem, but everything I read seems really over complicated. I just want to know the simplest way to get user input.</p>