View Full Version : JS and FormMail

11-21-2010, 06:32 PM

Google groups emails by “Subject.” Unfortunately, there is no way to keep emails with the same “Subject” separate. I am using FormMail to receive comments and questions from viewers. Before, I was specifying the “Subject” as “Comments/Questions.” Therefore, Google grouped all the emails. And, I wanted to keep the email separate.

To separate the emails, I changed the code as follows:


function is_filled()


[Here is some of the code used for validation which works fine!]


var subject_random="CQ" + Math.floor(Math.random)()+999999) + 1; [Here I set the



Then in FormMail, I show:

<input type="hidden" name="subject" value=subject_random>

When the form is submitted, the Subject in the email appears as “subject_random.”

Please help!

Thank you.

Dr. T.

Old Pedant
11-21-2010, 11:06 PM
You'd have to do

document.write('<input type="hidden" name="subject" value="' + subject_random + '">');

to create that field.

Or, if the field already exists, you could do

document.forms[0].subject.value = subject_random;

But that must be done *AFTER* the </form> tag is processed by the browser. So either put the JS at the end of the page or use <body onload="..."> to do it.