iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-15-2008, 07:10 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Email to send to based on drop down selection

Hi everyone! Can anyone advise me to a site that has a script or does anyone know of a script that can select what email address to send to based on what the user selects from the drop down box?

Any help will be totally appreciated...

MS
Reply With Quote
  #2 (permalink)  
Old 02-15-2008, 08:18 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

Well I can't leave any/everyone hanging so I'll post the code here - yes I figured it out and it works!

First the form and the drop down box:

Code:
                          <form onSubmit="return checkFields();" method="post" name="thisform" action="process.php" enctype="multipart/form-data">

                            <select name="worktype" size="1">
                                <option value="">Choose one</option>
                                <option value="General Contracting">General Contracting</option>
                                <option value="Fences and Decks">Fences and Decks</option>
                                <option value="Lanscaping and Interlocking">Lanscaping and Interlocking</option>
                                <option value="Garden and Design">Garden and Design</option>
                            </select>


                            <input type="hidden" name="recipient" value="nothing">


</form>
Now the javascript:

Code:
                             <script type="text/javascript">  
                          
                              function checkFields() {
                                
                               if (document.thisform.worktype.value == "General Contracting")
                                    {
                                document.thisform.recipient.value = "this@gmail.com";        
                                }

                                
                                if (document.thisform.worktype.value == "Fences and Decks")
                                    {
                                document.thisform.recipient.value = "that@gmail.com";        
                                }

                                
                                if (document.thisform.worktype.value == "")
                                    {
                                document.thisform.recipient.value = "those@gmail.com";        
                                }

                            }
                                                                                        
                            </script>
Again, it works and I thank those who tried to figure it out with me as well...
Reply With Quote
  #3 (permalink)  
Old 10-27-2009, 11:51 AM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

I am trying to do this same thing and I can't get the email portion to work.
I have changed the javascript to match my form name and in the email that I receive it populates the "recipient" field based on the drop-down I select.
But the email isn't being sent to that person at all.
My code is below.


Code:
<script type="text/javascript">  
 function checkFields() {
    if (document.facilityrequest.worktype.value == "Contact1")
    {
    document.facilityrequest.recipient.value = "contact1";        
    }
    if (document.facilityrequest.worktype.value == "Contact2")
    {
    document.facilityrequest.recipient.value = "contact2";        
    }
    if (document.facilityrequest.worktype.value == "")
    {
 document.facilityrequest.recipient.value = "my work email";        
    }
    }                                                                                    
</script>
The drop-down list (Only using options 1 and 2 for emailing as a test)

Code:
          <select name="worktype" size="1">
            <option value="">Choose one</option>
            <option value="Contact1">Contact1</option>
            <option value="Contact2">Contact2</option>
            <option value="Lanscaping and Interlocking">Lanscaping and Interlocking</option>
            <option value="Garden and Design">Garden and Design</option>
          </select>
          <input type="hidden" name="recipient" value="nothing" />
On my processing page I have the following and in my past examples of similar things it has worked but not this time. What doesnt seem to be working is in red. I dont see why that isn't working when I do this for other web forms of mine and it does.

Code:
<CFMAIL TO="my work email address"
CC= "#FORM.Contact_Email#, #FORM.Recipient#" 
BCC=""
FROM= ""
SUBJECT= "Facility Reservation Request Form (WebformWCAllowList)"
type="html">
<h3>Facility Reservation Request Form</h3>
<table width="100%"  border="0" cellspacing="0" cellpadding="0" style="border: 0px;padding: 5px;font-size: 12px;">
<cfloop index="x" list="#form.fieldnames#">
<tr><td style="border: solid 1px;">#x#</td><td style="border: solid 1px;">#form[x]#</td></tr>
</cfloop>
</table>
<cfsilent>
     <!--- Note that I used the <CFSILENT> tag, this will kill the white space in this area so your email is not cluttered with white space. --->
     <cfif FORM.Upload neq "">
        <cfmailparam file="#attachment_local_file_1#">
     </cfif>
</cfsilent>
</cfmail>
Reply With Quote
  #4 (permalink)  
Old 10-27-2009, 12:22 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

So what is the error you're getting?
__________________
Join free dating sites and meet single people without paying a penny.
Reply With Quote
  #5 (permalink)  
Old 10-27-2009, 12:25 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

Thats just it, i get no error.

But none of the recipients i specify on my process page receive the email based on that #FORM.RECIPIENT# tag. The cfmail to and the cc gets their email fine.
And in my email I receive the Recipient field is populating with the email address that the javascript says it needs to be, it just isnt getting emailed to that person.
Reply With Quote
  #6 (permalink)  
Old 10-27-2009, 12:28 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

I dont know what happened but everything i was seeing said it should be working and now all of a sudden it is. Maybe it was a hiccup on my coldfusion server. Sorry to bother you, great code, it works great.
Reply With Quote
  #7 (permalink)  
Old 10-27-2009, 12:40 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

Not a bother at all...the site I used that code on isn't live anymore but it's good that you reminded me for later use...and welcome to WPW!
__________________
Join free dating sites and meet single people without paying a penny.
Reply With Quote
  #8 (permalink)  
Old 10-27-2009, 12:49 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

I do actually have another request. I have about 10 checkboxes on my form and the end user would like it that if any of those check boxes are ticked, a separate email goes to a new person.
Any easy way to accomplish this?
Reply With Quote
  #9 (permalink)  
Old 10-27-2009, 01:35 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

This might help you along the way...


<input type="checkbox" name="email-address" value="abc@email.com">
<input type="checkbox" name="email-address" value="def@email.com">
<input type="checkbox" name="email-address" value="ghi@email.com">

Then in your CF process pass the checked values in "form.email-address" as a list...then loop through the list using CFLOOP and append the values to one variable separated by commas. (keep the name of the checkboxes the same in this case)

In the end you should have one variable - let's call it #CC-List# - with the email values.


<CFMAIL TO="my work email address"
CC= "#CC-List#"
FROM= ""
SUBJECT= "Facility Reservation Request Form (WebformWCAllowList)"
type="html">
</CFMAIL>


I haven't worked with coldfusion for years but I'm thinking this could get your started...although someone else could respond with much cleaner and more efficient way of doing this....
__________________
Join free dating sites and meet single people without paying a penny.

Last edited by morestar; 10-27-2009 at 01:38 PM.
Reply With Quote
  #10 (permalink)  
Old 10-27-2009, 01:42 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

Actually while waiting on your reply I stuck with the existing javascript by adding additional lines of

if (document.facilityrequest.Podium_with_Microphone.v alue == "Yes")
{
document.facilityrequest.Maintenance_Recipient.val ue = "maintenance email address";

And created another hidden text field like you used such as

<input type="hidden" name="maintenance_recipient" value="nothing" />

and on my cfmail added a cc of #form.maintenance_recipient# and it appears to be working.

The only thing that sucks is on my form i have about 10 check boxes and I am not sure how to code it that if ANY of the checkboxes are selected to send email to Maintenance, I will have to for now just manually add the 2 lines in the javascript for each of the check box names and tie it to the hidden text box of maintenance_recipient. That should work I think. I can show you the live page if you wish. I would send it in a PM not on the forum.

Last edited by DJ Ballistic; 10-27-2009 at 01:47 PM. Reason: Missing some text
Reply With Quote
  #11 (permalink)  
Old 10-27-2009, 02:04 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

Sounds good...

so what if you grab the values of the checkboxes as a list, into a variable?

From there your CC field should easily be set to the list variable no?

I think the values will all be separated by commas in ColdFusion.
__________________
Join free dating sites and meet single people without paying a penny.
Reply With Quote
  #12 (permalink)  
Old 10-27-2009, 02:06 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

I am not certain how to go about doing that to be honest. I am only an intermediate user of Cold Fusion.
Reply With Quote
  #13 (permalink)  
Old 10-27-2009, 02:25 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

maybe try:

<input type="checkbox" name="email-address" value="abc@email.com">
<input type="checkbox" name="email-address" value="def@email.com">
<input type="checkbox" name="email-address" value="ghi@email.com">

<cfset num-of-addresses=3>
<cfloop index="#num-of-addresses#" list="#email-address#">
<cfset CC-List=CC-List & #email-address#>
</cfloop>

<CFMAIL TO="my work email address"
CC= "#CC-List#"
FROM= ""
SUBJECT= "Facility Reservation Request Form (WebformWCAllowList)"
type="html">
</CFMAIL>

Tell me if this works at all...im trying im trying !!
__________________
Join free dating sites and meet single people without paying a penny.
Reply With Quote
  #14 (permalink)  
Old 10-27-2009, 02:30 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

The only problem I can see with changing he names of the checkboxes is I wont get the proper value that I need to see in the email. At least that's what I think. If checkbox is named "email_address" then the value of that checkbox, instead of being "Podium_With_Microphone" = Yes when selected, it would be Email_Address = Yes. Wouldn't it?
Reply With Quote
  #15 (permalink)  
Old 10-27-2009, 02:34 PM
morestar's Avatar
WebProWorld Veteran
WebProWorld MVP
 
Join Date: Jun 2007
Location: Burlington, Ontario (Toronto)
Posts: 940
morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5morestar RepRank 5
Default Re: Email to send to based on drop down selection

Oh yes well of course...i was just using those values as fillers but I see what you're saying...so the value in one case, for the checkbox would need to be "Podium_With_Microphone" and once that values is checked it emails to a certain address right?
__________________
Join free dating sites and meet single people without paying a penny.
Reply With Quote
  #16 (permalink)  
Old 10-27-2009, 02:36 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

You are correct except the same person gets emailed, maintenance, whether one checkbox is selected or all of them are. Nobody else gets emails with those checkboxes, it will only ever be Maintenance.
Reply With Quote
  #17 (permalink)  
Old 10-27-2009, 03:03 PM
WebProWorld New Member
 
Join Date: Oct 2009
Posts: 9
DJ Ballistic RepRank 0
Default Re: Email to send to based on drop down selection

The last task I will end up having to do is on that form I sent you, when they select the seating style, they want a link to click on that shows them a photo of that seating style. I haven't a clue how I am even going to accomplish this one. But luckily i haven't been told to do that yet, but I know it is coming.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What's the best time to send Email? wenwilder Marketing Strategies Discussion Forum 10 02-01-2008 11:15 PM
Profile Based Item Selection and Auto-Shipping? chrison600 eCommerce Discussion Forum 0 04-13-2007 12:46 AM
Help ! webproworld does not send me email notifications :( marcel WebProWorld: Guidelines/Announcements/Suggestions 12 01-19-2006 04:36 PM
how to send html based email bobkom Marketing Strategies Discussion Forum 5 11-10-2004 11:18 PM
mailform redirect based upon user selection twopooches Web Programming Discussion Forum 5 06-25-2004 04:26 PM


All times are GMT -4. The time now is 01:18 AM.



Search Engine Optimization by vBSEO 3.3.0