Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfmail trigger by select list

Engaged ,
Feb 19, 2014 Feb 19, 2014

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,

Regards,

Iccsi,

685
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2014 Feb 19, 2014

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  --->

<cfelse>

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

</cfif>

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

<cfselect name="mySelect">

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

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

</cfselect>

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

</cfform>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 19, 2014 Feb 19, 2014

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.

hth

reed

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 20, 2014 Feb 20, 2014
LATEST

Thanks for the information and help,

It works on both way,

Regards,

Iccsi,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources