Reputation: 7313
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>
Upvotes: 0
Views: 205
Reputation: 3778
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
Upvotes: 1