Reputation: 63
I'm creating a google add on for sheets. The sidebar I'm working on is intended to be sort of help ticket submission, but way before I can develop that part of things, I'm not getting the submit button in the form to call the javascript function I want to build.
I've removed all of the form data from the html button call to activate a Logger.log. No dice. I created a completely separate (and very simple) button to call a different function to call Logger.log. This also did not work. I've double checked the form data, the send call, and the function. I made sure the name of the function (sendMsg) is unique. I think that the issue may not be in my code but in some other way the html and javascript (.gs) are connected.
here is the html form:
<div class="block form-group">
<form>
<label for="reason">Purpose of Contact</label>
<select id="reason">
<option selected>Help Request</option>
<option>Feature Request</option>
<option>Error Report</option>
<option>Other</option>
</select>
<label for="email">Email</label>
<input type="text" id="email" style="width: 200px;">
<label for="phone">Phone</label>
<input type="text" id="phone" style="width: 120px;" value = "optional">
<br>
<label for="translated-text">
<b>Message</b></label>
<textarea id="userMsg" rows="15" cols="35">
</textarea>
<br>
<input id="app" name="appSrc" type="hidden" value="COE">
<input type="button" class="action" name="helpRequest" value="SEND" onClick="google.script.run.sendMsg(
document.getElementById('reason').value,
document.getElementById('email').value,
document.getElementById('phone').value,
document.getElementById('userMsg').value,
document.getElementById('appSrc').value
)" />
</form>
</div>
and here is the function called:
function sendMsg(appSrc,reason,email,phone,userMsg) {
appV = appSrc;
reasonV = reason;
emailV = email;
phoneV = phone;
userMsgV = userMsg;
Logger.log('cheese');
}
Right now the form should simply result in a Logger.log message. At this point nothing happens.
Upvotes: 0
Views: 2175
Reputation: 612
In case anyone has the same issue as I had... onpress
doesn't seem to work here. I had to change it to onclick
.
Upvotes: 0
Reputation: 201388
sendMsg()
at Google Apps Script side doesn't work.
sendMsg()
.If my understanding is correct, how about this modification?
<input id="app" name="appSrc" type="hidden" value="COE">
, appSrc
is not id. By this, an error occurs at document.getElementById('appSrc').value
, and sendMsg()
didn't work. So if your script is modified, for example, please use app
.document.getElementById('appSrc').value
document.getElementById('app').value
Or
<input id="app" name="appSrc" type="hidden" value="COE">
<input id="appSrc" name="appSrc" type="hidden" value="COE">
If I misunderstood your question and this was not the result you want, I apologize.
Upvotes: 3