TwiztedCupid Posted December 10, 2009 Share Posted December 10, 2009 Hi. I want to send an email to a specific person based on the selection made in a drop down list. I'm using Dreamweaver CS4 and Adobe Developer Toolbox for the existing code. Here is some of my code. This first part is where it sends the mail. I need to use the variable in the "setTo" line. I know if I use {Services} it will send it to the values selected in drop down. i.e. Tree@yahoo-inc.com; Service@yahoo-inc.com. function Trigger_SendEmail(&$tNG) { $emailObj = new tNG_Email($tNG); $emailObj->setFrom("webmaster@somewhere.com"); $emailObj->setTo("VARIABLE HAS TO GO HERE"); $emailObj->setCC("me@you.com"); $emailObj->setBCC(""); Here is the code for the select: <select name="Services" id="Services"> <option value="" <?php if (!(strcmp("", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Select a service...</option> <option value="Landscape Maintenance" <?php if (!(strcmp("Landscape Maintenance", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Maintenance</option> <option value="Landscape Design" <?php if (!(strcmp("Landscape Design", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Landscape Design</option> <option value="Planting Renovation" <?php if (!(strcmp("Planting Renovation", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Planting Renovation</option> <option value="Tree Service" <?php if (!(strcmp("Tree Service", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Tree Service</option> <option value="Snowplowing" <?php if (!(strcmp("Snowplowing", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Snowplowing</option> <option value="Other" <?php if (!(strcmp("Other", KT_escapeAttribute($row_rsestimate['Services'])))) {echo "selected=\"selected\"";} ?>>Other</option> </select> Is there a way if the user selects "Landscape Maintenance" or "Landscape Design" the email will go to "user1@somewhere.com". If they select "Tree Service" it will go to "user2@somewhere.com"? Something like: If Services = "Landscape Design" Or "Landscape Maintenance" Then $toEmail = "user1@somewhere.com" Else If Services = "Tree Service" Then $toEmail = "user2@somewhere.com"......and so on. Then place $toEmail into "$emailObj->setTo("$toEmail");"? Quote Link to comment Share on other sites More sharing options...
Buddski Posted December 10, 2009 Share Posted December 10, 2009 You could do something like this.. $emails_array = array( 'Landscape Maintenance'=>'email1@email.com', 'Landscape Design'=>'email2@email.com', 'Planting Renovation'=>'email3@email.com', 'Tree Service'=>'email4@email.com', 'Snowplowing'=>'email5@email.com', 'Other'=>'email6@email.com'); function Trigger_SendEmail(&$tNG) { global $emails_array; $emailObj = new tNG_Email($tNG); $emailObj->setFrom("webmaster@somewhere.com"); $emailObj->setTo($emails_array[$_POST['Services']]); $emailObj->setCC("me@you.com"); $emailObj->setBCC(""); } Not 100% certain but it should work Quote Link to comment Share on other sites More sharing options...
TwiztedCupid Posted December 10, 2009 Author Share Posted December 10, 2009 This worked like a charm. Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.