Jump to content

Archived

This topic is now archived and is closed to further replies.

kimeee

form radio button values = emails

Recommended Posts

I have set up a "Leave of Absence Request" form with HTML and PHP. When filled out and sent, it sends a copy to me.

They (my superiors) have also asked if I can set it up so that when a user clicks on a radio button for a specific department, a separate email will be sent to that dept, as well as the email to me.

I know this must be possible. I have tried many ways and have had no luck so far.

Is there anyone out there that can help me?

Share this post


Link to post
Share on other sites
Can you post the code your currently using?

Share this post


Link to post
Share on other sites
You can use a check box instead of the radio button like this

Example check box
[code]
<input type="checkbox" name="Department_name" value="Yes" /> Department Name
[/code]

in you php, you just need to add the extra email address to the "To"
[code]
$to = "your_email@domain.com";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", department_email@domain.com";
}
[/code]

Let me know if you need radio buttons and an example of your form if you need more help.

Share this post


Link to post
Share on other sites
nogray: i need to set it up with 4 radio buttons with 4 different emails for each button. how would this work? with elseif?

thanks!

[!--quoteo(post=380779:date=Jun 6 2006, 05:15 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ Jun 6 2006, 05:15 PM) [snapback]380779[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You can use a check box instead of the radio button like this

Example check box
[code]
<input type="checkbox" name="Department_name" value="Yes" /> Department Name
[/code]

in you php, you just need to add the extra email address to the "To"
[code]
$to = "your_email@domain.com";
if ($_POST['Department_name'] == "Yes"){
     $to .= ", department_email@domain.com";
}
[/code]

Let me know if you need radio buttons and an example of your form if you need more help.
[/quote]

Share this post


Link to post
Share on other sites
you can use something like this
[code]
<input type="radio" name="Email" value="Dep1" /> Dep1
<input type="radio" name="Email" value="Dep2" /> Dep1
<input type="radio" name="Email" value="Dep3" /> Dep1
<input type="radio" name="Email" value="Dep4" /> Dep1
[/code]

and your php
[code]
$to = "your_email@domain.com";
if ($_POST['Email'] == "Dep1"){
     $to .= ", dept1_email@domain.com, dept1_email@domain.com, dept1_email@domain.com, dept1_email@domain.com";
}
else if ($_POST['Email'] == "Dep2"){
     $to .= ", dept2_email@domain.com, dept2_email@domain.com, dept2_email@domain.com, dept2_email@domain.com";
}
else if ($_POST['Email'] == "Dep3"){
     $to .= ", dept3_email@domain.com, dept3_email@domain.com, dept3_email@domain.com, dept3_email@domain.com";
}
else {
     $to .= ", dept4_email@domain.com, dept4_email@domain.com, dept4_email@domain.com, dept4_email@domain.com";
}

[/code]

Hope this helps you.

Share this post


Link to post
Share on other sites
assuming that each department has the same domain for their email address..you don't need all those if statements. just pass the email name and add the @domain.com to the passed variable.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.