This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
send email based on value selected in the combo box.
Started 15 years ago by raj000 | 2 posts |
-
I have a list of products that we sell listed in a combo box field. There are approximately 30 values in the combo box and increasing. When an entry is submitted, a notification is sent to sales@example.com. For most of the products, the same email address would be notified. However, for a few of the products, maybe 2 or 3, the email notification will be sent to a different department.
I have been following another thread on this subject -:
http://www.appnitro.com/forums/topic/email-from-a-drop-downlist?replies=10
This does not really serve my purpose because in the above code i need to define the email notification address for each option in the combo. I want to use the default email settings for the form for most of the options. I only want to modify the code when the email to be notified is different from the standard email notification setting.
Please help . Thanks
Posted 15 years ago # -
Hi,
I think you can add some conditional to "custom hook" code, you can change from the original code to be like this :
function form18_hook_email($params){ //change the email addresses below $email_list[2] = 'hrd@example.com'; $email_list[4] = 'accounts@example.com'; $res = do_query("select element_3 from ap_form_{$params['form_id']} where id='{$params['entry_id']}'"); $row = do_fetch_result($res); $attn = $row['element_3']; if (array_key_exists($attn, $email_list)) $target_email = $email_list[$attn]; else $target_email = 'test@test.com'; if(!empty($target_email)){ return $target_email; }else { return true; } }
in that example you only have non-standard email for option value 2 and 4. And for another value it will send same email that is test[at]test.com.
MachForm Support
Posted 15 years ago #
Reply
You must log in to post.