3 Replies Latest reply on Feb 20, 2014 2:00 PM by iccsi

    cfmail trigger by select list

    iccsi Level 1

      I need to send an email when user change select list.

      I can use cfmail to send out email, I would like to know is it possible to trigger the mail when user click and change the select list or I have to use when user click a button,


      Your help and information is great appreciated,






        • 1. Re: cfmail trigger by select list
          BKBK Adobe Community Professional & MVP

          I would just submit the form to its own page. Yes, using the submit button. For example,


          <cfif isDefined("form.mySelect") and form.mySelect is 1>

          <!--- Send mail  --->


          <!--- Do something else or nothing --->



          <cfform action="#cgi.SCRIPT_NAME#">

          <cfselect name="mySelect">

          <option value="1">Yes</option>

          <option value="0">No</option>


          <cfinput name="sbmt" type="submit" value="send">


          • 2. Re: cfmail trigger by select list
            REEDPOWELL Level 1

            It is a multi-step process, but yes you can do this.  Put an onChange() handler on the SELECT or CFSELECT statement.  Have it call window.open() to open up in a new window/tab the CFM script that will send the email.  If you want to pass parameters to it from the page with the SELECT statement, they will need exist somewhere in the DOM of the page with your SELECT statement (such as the current value of the SELECT).  The JS function that you have the onChange() call can build the string that will be used as the URL in the window.open, or you can just build one long hellacious onChange() argument.  In the CFM script that gets loaded by window.open you do the CFMAIL and whatever else needs to be done, and then at the end use a window.close() to have the window close itself.  Some browsers will be a nuisance on this last part and ask the user to confirm the window closing, others will just close the window. The net result is that you end up back on the same page as the SELECT statement with no changes having been made to it.  You just need to keep clear in your mind what is running on the CF server to build the page and what is running in the browser once the page is rendered and begins executing any handlers, javascript, etc.




            • 3. Re: cfmail trigger by select list
              iccsi Level 1

              Thanks for the information and help,

              It works on both way,