User selects 'To' recipient address from drop-down

formadmin 17 Jul, 2012
I've been working with Max to setup a drop-down box that allows a user to select who they would like to send the form email to. These recipients are listed in the drop-down by department, and each department has an associated email address. I've followed Max' directions on how to set this up, but I'm not getting the correct addresses when the form is submitted. Since he is away, he asked that I post this question here on the forum in the hope that someone (Bob) could help me quickly.

Here is the selectbox code I'm using in the form:

<select name="dmail" id="dmail">
  <option value="0">General Inquiry</option>
  <option value="1">Adverse Event Reporting</option>
  <option value="2">Product Complaint Reporting</option>
  <option value="3">Business Development</option>
  <option value="4">Investor Relations</option>
</select>


And here is the Custom Code action I'm using in my On-submit, before my Send Email action:

<?php
$emails = array('address1@company.com', 'address2@company.com', 'address3@company.com', 'address4@company.com', 'address5@company.com');
$form->data['demail'] = $emails[$form->data["demail"]];
?>


I also have 'demail' in the Dynamic To field in my Send Email action.

This actually DOES add the selectbox value to the To field in the outbound email, but the actual address is not getting applied.

This form needs to go live in about an hour, if there is any way someone can assist me, I'd really appreciate it.

Thanks,

JD
formadmin 17 Jul, 2012
I have found the reason this isn't working... I had 'dmail' in the selectbox name field when it should have been 'demail'. This is now working perfectly.

One other question though; it seems that I'm forced to have a static To address, in addition to my dynamic To address... is there any way to just have the dynamic one without the static one?

Thanks,

JD
GreyHead 17 Jul, 2012
Hi JD,

You shouldn't normally need both Static and Dynamic To addresses; provided that one is present and is a valid email address all should be OK.

Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Note: if you are using the Easy Wizard you may need to switch to the Advanced Wizard to do this; if you want to continue to use the Easy Wizard please make a copy of your form first and add the Debugger action to the copy.

Bob
This topic is locked and no more replies can be posted.