learn-to-send-email-via-google-script-html-no-server icon indicating copy to clipboard operation
learn-to-send-email-via-google-script-html-no-server copied to clipboard

Hide hidden input fields in email

Open rfingerlos opened this issue 2 years ago • 3 comments

If my previous issue, that I found the answer to and closed, wasn't seen, THANK YOU for this script, your work is greatly appreciated!!!

Now, I was wanting to "hide" some of the input fields from posting to the sheet, which following some examples in previously closed issues, I was able to do, however, those inputs that are now not showing in the sheet are still showing in the email? Would there be a way to trim them out of the email as well?

The form I'm making is for an automotive repair facility, I have separate fields for the vehicles year, make, model, engine. My idea was to have them entered individually, but then run another script on the page that will concatenate the 4 fields into a hidden input that I do want to be pulled to the sheet/email. This way there is a basic format set for the vehicle information so each time the form is submitted the vehicle information is always in the same format.

So far everything is working perfectly, except that the inputs I want to be hidden from the sheet are still showing in the email.

Thanks,

rfingerlos avatar Feb 11 '22 00:02 rfingerlos

Thought I had this figured out so I closed it. Come to find out, it was;t working as intended. Still looking for feedback here.

Thanks,

rfingerlos avatar Feb 11 '22 21:02 rfingerlos

Glad to hear the script has been helpful!

How did you hide the fields in the google sheet? Is it by hiding the columns or removing the fields in the google script?

One solution is to remove the fields in the clientside javascript, then it won’t be sent to either. I believe that’s how the honeypot fields work. I’d probably just use a new class name for your fields and filter them out.

mckennapsean avatar Feb 12 '22 17:02 mckennapsean

I hid the fields from the sheets by hiding the columns. Issue #306 & #403 helped me overcome that.

I was looking at #176 for hiding the honeypot from emails, in hopes that it would help guide me on how to remove my fields from the emails, and this is where I came into problems. I am a total novice here, and the example given in the issue doesn't directly lead me to where and how to make the changes to the clientside script.

Here is what I have so far that semi-works...

var fields = Object.keys(elements).filter(function(k) {
      if (elements[k].name === "honeypot" || elements[k].name === "make" || elements[k].name === "model" || elements[k].name === "year" || elements[k].name === "cid") {
        honeypot = elements[k].value;
        return false;
      }

honeypot, make, model, year fields all seem to work correctly, regardless of whether there is data entered into the fields or not. When I leave the "cid" field empty on the form, the script runs properly, no data is posted to the sheet, email is sent with the 4 missing fields as it should. But as soon as I enter data into the "cid" field, the script does not run after pressing submit. The page sits idle, no thank you message displays, no data posts to sheet, no email is sent, and this is where I'm stumped. With the "cid" field being the only issue, I have renamed it both in the script and my form to make sure the name wasn't causing the issue and the results were the same. Like I mentioned previously, I'm pretty clueless as to what I'm doing, figuring I have made a huge mistake somewhere, but idk...

rfingerlos avatar Feb 15 '22 21:02 rfingerlos