I have an e-mail form where the end user needs to select where the e-mail needs to go. The client wishes for this to be a required field, so if no option is selected from the dropdown box, he doesn't want the email to send, and an error message needs to display.
I have this working one way or the other (meaning: I can have the dropdown box switch to different e-mail addresses per user selection and it will send; or I can make it required to select an option from the dropdown box, and an error will display if no option is selected) - but it won't do both. If I try to make them function together, the error is displayed if nothing is chosen from the dropdown box, and a "Thank you" page appears - but the e-mail never comes to my inbox. If I remove the required fields stuff - the email comes through just fine.
In my PHP file, I have this for the dropdown box stuff:
switch($mailto) {
case "sales":
$mailto = "email1@test.com";
break;
case "partners":
$mailto = "email2@test.com";
break;
case "support":
$mailto = "email3@test.com";
break;
case "other":
$mailto = "email4@test.com";
}
There is no "default" set, because if I set one, then the required thing doesn't work.
In the HTML document (called in as an include from the PHP file) I have this:
<b <? if ($mailtoerror!= "")?> >What is the nature of your inquiry?</b>
<select class="form" name="mailto">
<option value="" selected></option>
<option name="sales">Sales</option>
<option name="partners">Customer Support</option>
<option name="support">Partners</option>
<option name="other">Other</option>
</select>
Would anyone know, from looking at this, why the e-mails won't come through when I try to make the field required? (Or should I just show you the entire files?) It's as simple as removing "selected" from the blank option value to get the e-mail to come through - but if I don't have it there, then the "requiredness" of the field is gone.
Any help would be appreciated 🙂