Note that there are some explanatory texts on larger screens.

plurals
  1. POCall checkbox value if checked from html file in javascript function
    primarykey
    data
    text
    <p>I have two files: myPage.html and myCode.gs in google scripts. I have deployed the html file as a web app, and I have figured out (with help) how to make the onclick event for the 'submit' button to trigger the emailTech function from the myCode.gs file just fine. I have also been able to insert the value from the text box in the html file into the email that is called from the onClick event. </p> <p>I also have two check boxes and if checked, I would like to have their values entered into the email triggered by the onClick event. I have tried various versions of 'if checked then' statements both in the script tage of the html file and in the emailTech function but neither seem to work. Any suggestions? </p> <p>myPage.html file: </p> <pre><code>&lt;head&gt; &lt;title&gt;Test Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;input type="text" value=" " name="techEmail" /&gt; &lt;input type="checkbox" name="checkone" value="checkone" /&gt;Checkone &lt;input type="checkbox" name="checktow" value="checktwo" /&gt;Checktwo &lt;input type="button" onClick="formSubmit()" value="Submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;script type="text/javascript"&gt; function formSubmit() { google.script.run.emailTech(document.forms[0]); } &lt;/script&gt; </code></pre> <p></p> <p>myCode.gs file:</p> <pre><code>function doGet() { return HtmlService.createHtmlOutputFromFile('myPage'); } function emailTech(form){ //I want something along the lines of: //if form.checkone == "checked"{ //var checkone = "checkone" //} //if form.checktwo == "checked"{ //var checktwo = "checktwo" //} var nameBox = form.techEmail; var message = "This is the text box value" + nameBox + checkone + checktwo; MailApp.sendEmail("email@somewhere.com", "This is the subject", message ); } </code></pre> <p>Also, is there a way to clear the textbox and checkboxes when the submit button is clicked? I don't want to have a seperate reset button, I'd like this to reset and send the email with one click if possible. Thanks in advance! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload