Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: JS and FormMail

  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Location
    Guttenberg, NJ
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS and FormMail

    Hi!

    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:

    <script>

    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

    variable]

    </script>

    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.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You'd have to do
    Code:
    document.write('<input type="hidden" name="subject" value="' + subject_random + '">');
    to create that field.

    Or, if the field already exists, you could do
    Code:
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •