Forums

Dynamic recipient form

betty111111 19 May, 2009
I was trying to create one form that would email the correct person based on the Dropdown selection, aka a dynamic recipient form, but I did not want to simply use the "Dynamic To" option and display the email addresses.

Here's what I did and I thought I'd share since other people seems to ask about it and I never found a simple answer.

1. In your form add a Dropdown (eg. select_0) full of names (eg. Bob, Sue)
2. In your form add a Hidden field (eg. hidden_0)
3. Enable the form to email and set the "Dynamic To" to hidden_0
4. In "Form Code" and the in "On Submit code - before sending email:" I used the following code:

<?php
if ($_POST['select_0'] == "Bob") {
$_POST['hidden_0'] = "bob@example.com";
} elseif ($_POST['select_0'] == "Sue") {
$_POST['hidden_0'] = "sue@example.com";
}
?>
GreyHead 19 May, 2009
Hi betty111111,

Thanks for that - very useful.

Bob

PS There's a version of this for a longer email list in one of the FAQs.
This topic is locked and no more replies can be posted.