Following up on ToggleButton for Google HtmlService, of which it says in the end:
In the HTML demo code that I provided, I was able to make use of
form.myButton.value, but the problem is when I try to use that to update my label from within Google App Code function, just as what the HTML demo code is doing, it always fails and I don't know why.
Here are the details:
HTML
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <h2>Feedback Form</h2>
    <div id="message" style="color:green"></div>
    <form id="myForm">
      <br /><input id="name" type="text" name="name" placeholder="Your Name">
      <br /><input id="email" type="email" name="email" placeholder="Your Email">
      <br /><input type="button" name="myButton" value="OFF" style="color:blue"
       onclick="toggle(this);">
      <br /><textarea id="comment" rows="10" cols="40" name="comment"></textarea>
      <br /><input type="button" value="Submit" onclick="submitForm(this.parentNode);" />  
    </form>  
    <script>
      var state = false;
      // Toggles the passed button from OFF to ON and vice-versa.
      function toggle(button) {
        state = !state;
        if (state) {
          button.value = "ON";
        } else {
          button.value = "OFF";
        }
      }
      function submitForm(form) {
        google.script.run
        .withSuccessHandler(function(value){
          document.getElementById('message').innerHTML = value;
          document.getElementById("myForm").reset();
        }) 
        .submitData(form);
      }
    </script>
  </body>
</html>
GAS
// https://stackoverflow.com/questions/59583876/google-apps-script-html-form/
//It works as a dialog
function showTheDialog() {
  var userInterface=HtmlService.createHtmlOutputFromFile('Index');
  SpreadsheetApp.getUi().showModelessDialog(userInterface, "Form")
}
// Test at
// https://jsbin.com/vodamekuxu/edit?html,js,console,output
function submitData(form) {
  Logger.log('name: %s <br />Email: %s<br />Comment: %s', form.name,form.email,form.comment);
  return Utilities.formatString('name: %s <br />Email: %s<br />Comment: %s', form.name,form.email,form.comment);
  //return Utilities.formatString('name: %s <br />Email: %s<br />Toggle: %s<br />Comment: %s', form.name,form.email,form.myButton,form.comment);
}
Again, the problem is when I try to update my label from within Google App Code function, just as what the HTML demo code is doing, it always fails and I don't know why.
The above code works, but if switching to use the 2nd return, it will fail (I believe because of the form.myButton part).
 
    