0

Like much of other examples provided by Google on Google scripts, modifying HTML through Javascript inside a success handler doesn't seem to work.

The example is:

<script>
  function updateUrl(url) {
    var div = document.getElementById('output');
    div.innerHTML = '<a href="' + url + '">Got it!</a>';
  }
</script>
<form id="myForm">
  <input name="myFile" type="file" />
  <input type="button" value="Submit"
      onclick="google.script.run
          .withSuccessHandler(updateUrl)
          .processForm(this.parentNode)" />
</form>
<div id="output"></div>

And I've done something quite similar:

<script>
    function clearList(someValue){
        document.getElementById('studentsForm').reset()
    }
    function setStatus(someValue){
        var status = document.getElementById('status');
        status.innerHTML = 'Remark posted.'
    }
</script>

<form name='studentsForm' id='studentsForm'>
    <select name='student'>
        <option value='none'>Select a student...</option>
        options
    </select>
    <br>
    <br>
    <textarea name='comment' rows='10' cols='35'>Type your comment here</textarea><br><br>
    <input type='button' value='Submit' onclick='google.script.run
                                                 .withSuccessHandler(setStatus)
                                                 .processRemark(this.parentNode)'>
</form>
<div id="status"></div>

I've tried running both clearList() and setStatus() functions but neither affected the HTML GUI even thought the server-side function was run successfully.

Is there something else to be done for this to work? Thanks.

Edit: In fact, to illustrate the problem isn't about a server-client communication issue (as far as I understand it), here is a simplified version of the code, with which the HTML isn't modified through the script function call:

<script>
function setStatus(){
  var status = document.getElementById('status');
  status.innerHTML = 'Remark posted.'
}
</script>
<input type='button' value='Test' onclick='setStatus();'>
<div id="status"></div>
gevorg
  • 4,835
  • 4
  • 35
  • 52
neydroydrec
  • 6,973
  • 9
  • 57
  • 89

1 Answers1

1

Just realised the input file, it doesn't work that way with IFRAME sandbox, see issue 4610, a workaround is present in the posts.

Here's my workaround for multiple files: Uploading Multiple Files to Google Drive with Google App Script

Community
  • 1
  • 1
Kriggs
  • 3,731
  • 1
  • 15
  • 23
  • What is the input file you are referring to? – neydroydrec Jul 24 '15 at 04:31
  • Sorry, I'll need a bit more of guidance please. I'm not sure to understand what the problem is in the first place. – neydroydrec Jul 24 '15 at 06:07
  • Your first HTML code has an ` – Kriggs Jul 24 '15 at 10:33
  • The bug comments specify: "Forms without file inputs should work correctly." However, in my case I'm not trying to upload a file. I'm simply submitting the form and expect a return to the HTML so I can amend the HTML. That return doesn't work though. – neydroydrec Jul 25 '15 at 08:55
  • I've updated the op with a simplified HTML showing how the HTML doesn't get modified through a script call, even though I'm not making any call to a server-side function. – neydroydrec Jul 25 '15 at 09:05