title: gs function passing 'undefined' to jsfunction (Dynamic Form Update)
body: <p>I'm having a problem with a dynamically updated form in Google Apps Script. <br />The form is in an HTML template (say index.html) as follows:</p>
  
  <pre><code>&lt;form id="login"&gt;
  &lt;p&gt;Enter username and password below, or use the links to the right for more services:&lt;/p&gt;
  &lt;input type="text" placeholder="username" id="username" name="username" /&gt;
  &lt;input type="password" placeholder="password" id="password" name="password"/&gt;
  &lt;input type="button" value="Login" onclick="google.script.run.withSuccessHandler(form_login).processForm(this.parentNode)" id="login_button" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>There is also a div designated for the output:</p>
  
  <pre><code>&lt;div id="output"&gt;test value&lt;/div&gt;
  </code></pre>
  
  <p>And a javascript function to update said div:</p>
  
  <pre><code>function form_login(msg) {
      var div = document.getElementById('output');
      div.innerHTML = div.innerHTML+msg;
    }
  </code></pre>
  
  <p>The function within the gs file that deals with this is as follows:</p>
  
  <pre><code>function form_login(formObject) {
    //connect to users spread sheet 
    var userssheet = SpreadsheetApp.openById("SPREADSHEET-ID-STRING");
  
    //get variables handed over and existing on page
    var username = formObject.username;
    var pass = formObject.password;
  
    //get where data range in spreadsheet
    var searchrange = userssheet.getActiveSheet().getDataRange();
  
    //check if username exists and return password (change to check if password and username are correct and)
    if (find(username, searchrange)) {
      var enteredpassword = searchrange.getCell(find(username, searchrange),4).getValue();
      var message = (username+" Found! Password is "+enteredpassword); //get password value
    } else {
      var message =  (username+" Not Found!");
    }
  
    //check if password entered is correct
    if (enteredpassword) {
      if (enteredpassword==pass) {
        message = message + "Correct Password";
      } else {
        message = message + "Incorrect Password";     
      }
    }
    return message;
  }
  </code></pre>
  
  <p>(Obviously I'm still building the functionality). </p>
  
  <p>The problem, which will probably turn out to be an obvious oversight on my part, is with the gs function. Whatever it returns is outputted as 'undefined' into the HTML. Even when i change <code>return message;</code> in the function to something like <code>return "hello";</code>, I still get undefined appended to the output div (I tried using <code>toString();</code> in the javascript function, but that didn't change anything). </p>
  
  <p>Any ideas? What am I missing?</p>