Ability to let the user choose who they want to email from a dropdown list? 
Posted: 30 October 2007 02:42 PM   [ Ignore ]
Sr. Member
RankRankRankRank
Total Posts:  153
Joined  2007-02-19

I’ve been trying to figure this out for a month or so now with no luck whatsoever.

I’m using FreeForm for our company’s site in which the user should be able to choose what department they want to get in contact with. I’m looking to have a simple drop down select menu with the different department names and the corresponding email addresses for each department. After the user selects which department they want to get in contact with, that department’s email address will be notified the same way I would be notified if I filled in the “notify” parameter with my own email

Here is what I’ve got so far:

{exp:freeform:form form_id="contact" return="static/thank-you" required="name|email|subject|message" template="contact_form"}

 
<select name="recipients" id="recipients">
 <
option selected="selected">-- Deliver To --</option>
 <
option value="<?php echo base64_encode('department_email_address'); ?>">Department 1</option>
 <
option value="<?php echo base64_encode('department_email_address'); ?>">Department 2</option>
 <
option value="<?php echo base64_encode('department_email_address'); ?>">Department 3</option>
 </
select>

 <
div class="contactfield"><label for="name">Your name:</label> <span class="requiredfield">(required)</span><br />
 <
input type="text" class="required validate-alpha" id="name" name="name" /> 
 </
div>

 <
div class="contactfield"><label for="email">Your e-mail address:</label> <span class="requiredfield">(required)</span><br />
 <
input type="text" class="required validate-email" id="email" name="email" />
 </
div>

 <
div class="contactfield"><label for="subject">Subject:</label> <span class="requiredfield">(required)</span><br />
 <
input type="text" class="required" name="subject"  id="subject" />
 </
div>

 <
div class="contactfield"><label for="message">Message:</label> <span class="requiredfield">(required)</span><br />
 <
textarea class="required" name="message" id="message"></textarea>
 </
div>

 <
div class="contactfield">
 <
input type="submit" name="Submit" value="Submit" class="submit" />
 </
div>

 
{/exp:freeform:form}

I realize this code will not work, but you can see where I’m trying to go with it. I just can’t get the connection right so that the user can choose the email address (department) they want to contact and have that same email address be the one that is “notified”.

If anyone has any ideas I’d greatly appreciate it.

Profile
 
 
Posted: 23 January 2008 10:13 AM   [ Ignore ]   [ # 1 ]
Jr. Member
RankRank
Total Posts:  35
Joined  2007-04-27

Has anyone figured this out? We’re working on a site that needs this same functionality (i.e., choosing the recipient from a drop down menu).

Edit: Just read this post and was wondering if there’s been any progress on building the feature in? I saw the suggestion for procmail, but I’m 99% sure that won’t be possible.

.angie

Profile
 
 
Posted: 23 January 2008 11:38 AM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  701
Joined  2004-03-30

This is on our list. We’ll have that change in the next version. But yes, that may take a little bit of time.

mk

 Signature 

Mitchell Kimbrough

Profile
 
 
Posted: 23 January 2008 06:45 PM   [ Ignore ]   [ # 3 ]
Jr. Member
RankRank
Total Posts:  35
Joined  2007-04-27

Good to know. Thank you!

Profile
 
 
Posted: 13 February 2008 04:55 PM   [ Ignore ]   [ # 4 ]
Newbie
Avatar
Rank
Total Posts:  16
Joined  2007-07-03

Ditto. Looking for exactly the same thing for a club site - different topics get email to different club committee members chosen by the user from a drop down.

Profile
 
 
Posted: 13 February 2008 06:13 PM   [ Ignore ]   [ # 5 ]
Newbie
Avatar
Rank
Total Posts:  16
Joined  2007-07-03

Just a thought on how to do this - have an extra field in the template for “To Email” and in here you would put the custom field for your drop down - in deronsizemore’s example code at the start of this thread he has chosen “selected” - that would then give the form an email address to send it to as chosen from the list by the user.

Image Attachments
multi_recipients.gif
Profile
 
 
Posted: 13 February 2008 07:21 PM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  17
Joined  2007-11-28

Not an ideal solution but you could have the ‘select a department’ dropdown as a standalone form which then jumps to the rest of the form with the notify field filled with the appropriate value when the user selects an option.

Profile
 
 
Posted: 28 February 2008 03:27 PM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  10
Joined  2007-10-22

Has there been any progress on this? This is something I’d dearly love to be able to do with freeform instead of having to use EE’s contact form plugin for it.

Profile
 
 
Posted: 28 February 2008 03:34 PM   [ Ignore ]   [ # 8 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3232
Joined  2006-10-18

Not yet wink

 Signature 
Profile
 
 
Posted: 28 February 2008 04:05 PM   [ Ignore ]   [ # 9 ]
Newbie
Rank
Total Posts:  10
Joined  2007-10-22

Figured out a way around this…

<!--
function 
notifyEmail() {
var notifyEmail document.getElementById('notify').value;
window location "{site_url}index.php/contact_us/"+notifyEmail// remove the spaces for it to work
}
{if segment_2 
== ""}
window
.onload = function() {
notifyEmail
();
}
{
/if}
-->

{if segment_2 == "email@test.com"}
{exp
:freeform:form require_ip="yes" required="first_name|last_name|email|phone" notify="email@test.com" template="contact_us" form_name="contact_us" return="{segment_1}/thank_you"}
{
/if}
<table width="280" border="0" cellspacing="0" cellpadding="3">
<
tr>
<
td colspan="2">Department:</td>
</
tr>
<
tr>
<
td colspan="2">
<
select name="notify" id="notify" onchange="notifyEmail()">
{embed="contact_us/.departments"}
</select>
</
td>

Here’s the pertinent code in the base template, and then in a separate template I have it populate my options:

{exp:weblog:entries weblog="departments" dynamic="off" disable="categories|pagination|member_data|trackbacks" orderby="title" sort="asc"}
<option value="{url_title}" {if segment_2 == url_title}selected="selected"{/if}>{title}</option>
{/exp:weblog:entries}

The javascript switches out the segment_2 in the query string, which adjusts the weblog entry which controls the notify e-mail. Not especially elegeant, but it works.

EDIT: added code that forces the segment_2 variable to appear on window.onload, but only if there isn’t a segment_2 already.

EDIT 2: couldn’t get the first way to work, so had to construct an if statement that swaps out the starting exp:freeform tag.

Profile
 
 
Posted: 15 July 2008 07:00 PM   [ Ignore ]   [ # 10 ]
Member
Avatar
RankRankRank
Total Posts:  51
Joined  2006-09-11

@lifeboat: I’m trying to get your method to work with the JavaScript. I was a little surprised there is no easy way to select who the email gets sent to through any of the fields. I’m hoping that the resulting “notify=’{segment_3}’” will work.

@Simon Cox: Does your method work, putting the contents of a “to” field in the control panel as the to address? If that works, I may go that route. I need something to be able to select which salesperson to email.

Profile
 
 
Posted: 16 July 2008 03:04 PM   [ Ignore ]   [ # 11 ]
Newbie
Avatar
Rank
Total Posts:  16
Joined  2007-07-03

mdesign - my ‘method’ was actually a feature request or rather an idea on how Solspace might do this feature - so no you cannot do it presently

Profile
 
 
Posted: 16 July 2008 03:07 PM   [ Ignore ]   [ # 12 ]
Member
Avatar
RankRankRank
Total Posts:  51
Joined  2006-09-11

Thanks Simon...I found that out when I looked at the CP. Should have read your post more carefully. I’m using a {segment_3} and some JavaScript solution as first outlined by lifeboat. Not ideal, but working.

Profile
 
 
Posted: 17 July 2008 08:43 AM   [ Ignore ]   [ # 13 ]
Member
Avatar
RankRankRank
Total Posts:  51
Joined  2006-09-11

OK, this is NOT working, because I need to pass some $_POST variables from another page. When I get to the contact form though, I need to select a salesperson and that refreshes the page, and I lose those $_POST vars.

Is there ANY way (perhaps using jQuery) to populate the notify parameter I’m open to a hack as well, if anyone has done an unsupported hack.

Is there a method I can use employing one of the hooks, either freeform_module_insert_end or freeform_module_insert_end? Maybe send an extra email at that point?

Profile