Jump to content


Photo

form radio button values = emails


  • Please log in to reply
5 replies to this topic

#1 kimeee

kimeee
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 06 June 2006 - 08:25 PM

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?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 June 2006 - 08:43 PM

Can you post the code your currently using?

#3 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 06 June 2006 - 09:15 PM

You can use a check box instead of the radio button like this

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

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

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

NoGray.com


#4 kimeee

kimeee
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 08 June 2006 - 07:59 PM

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
You can use a check box instead of the radio button like this

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

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

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


#5 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 08 June 2006 - 08:34 PM

you can use something like this
<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

and your php
$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";
}


Hope this helps you.


NoGray.com


#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 June 2006 - 08:38 PM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users