After a previous question about passing values between GS and html I made some progress. I am able to store a text input value from a html sidebar into the Google propertiesservice and then pass it back to the sidebar upon opening this again. This however does not seem to work for my radio button. Anyone who can help me with this issue?
The code below processes the input from the sidebar
function processForm(form) {
radio = form.radioEmail;
userProperties.setProperty('selectedRadio', radio);
time = form.time;
userProperties.setProperty('selectedTime', time);
};
And the following codes places the stored inpout into the html sidebar:
function openTasksSettings() {
var htmlTemplate = HtmlService.createTemplateFromFile('tasksSettings');
htmlTemplate.timehtml = time;
htmlTemplate.radiohtml = radio;
var html = htmlTemplate.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle('Settings')
.setWidth(300)
SpreadsheetApp.getUi()
.showSidebar(html);
return html
};
And finally the html code (minus non-related parts)
<div>
<form>
<strong>Send email reminders:</strong><br>
<input type="radio" name="radioEmail" id="radio1" value="<?!= radiohtml ?>" Yes>
<label for="radio1">Yes</label>
<input type="radio" name="radioEmail" id="radio2" value="<?!= radiohtml ?>" No>
<label for="radio2">No</label><br><br>
<strong>Send reminders:</strong><br>
<input type="text" name="time" id="time" style="width: 40px;" value="<?!= timehtml ?>">
<label for="select">days before due date</label>
<br><br><input type="button" class="action" onClick="writeFormData(); alert('submitted')" value="Submit"/>
</form>
</div>
<script type="text/javascript">
function writeFormData() {
google.script.run.processForm(document.forms[0]);
}
</script>
Although it doesnt seem to affect storing and passing the time value I do get the following error when debugging the GS code:
TypeError: Cannot read property "radioEmail" from undefined
Any help would be appreciated!