Forums

I want to decide which person the email obtain

Spoona 26 Nov, 2008
Hi Guys,

sorry for my bad english.

I createt a form. All works perfect.

Thats the problem:

I created a "DropDownMenu" with 4 entrys. "Webmaster" "Administrator" "John" "Michael"

When the person chooses "Administrator", the mail should go to [email]administrator@domain.com[/email]
When the person chooses "John", the mail should go to "John@domain.com"


How can i realize this?
I tried the dynamic"to" field. But it didnt work.

Can someone help me?


Greetz
Spoona 27 Nov, 2008
Hi admin,

thanks for reply.

I don't know, which tag I have to put in for the boxes.

This is a sample form:
<div  class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Your name</label>
    <input class="cf_inputbox" maxlength="150" size="30" id="text_0" name="text_0" type="text">
  </div>
  <div class="clear"> </div>
</div>
<div  class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label">Which person do you want to contact</label>
    <select class="cf_inputbox" id="select_1" size="1" name="select_1">
      <option value="person 1">person 1</option>
      <option value="person 2">person 2</option>
      <option value="person 3">person 3</option>
    </select>
  </div>
  <div class="clear"> </div>
</div>
In the sample link you wrote there is the value "box1" "box2" "box3".
What I have to put in for the dropdown field?

Greez
GreyHead 27 Nov, 2008
Hi Spoona,

I reformatted your form code for clarity. It looks to me like the equivalent of 'box1' is 'person1' etc.

Bob
Spoona 27 Nov, 2008
Hi Bob,

thanks for helping me to make a better overview🙂=

I although thought, that I have to reset the "box1" with "person1".
"box2" with "person2" and so on.

But it didn't worked.
I altough tried to use "select_1" but it didn't work :-(


I created 3 "to" mail forms.
And put in three different mail accounts.
But it didn't work :/

Sorry for my bad english :/

Greez
Max_admin 27 Nov, 2008
Hi Spoona,

as I said you must make some changes to the code at that post, here its to work with Bob's code above :


    if(JRequest::getVar('select_1') == "person 1")$emails[0]->to = 'manager1@domain.com';
    if(JRequest::getVar('select_1') == "person 2")$emails[0]->to = 'manager2@domain.com';
    if(JRequest::getVar('select_1') == "person 3")$emails[0]->to = 'manager3@domain.com';



Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Spoona 27 Nov, 2008
Hi,

thanks for helping.

I tried but it didn't work😟

I have three Email adresses in the "To Field". "Foobar1@gmx.de" "Foobar2@gmx.de" "Foobar3@gmx.de" (separated by commas)

I added your code at

On Submit code - before sending email:
(PHP code with tags)


This code:
if(JRequest::getVar('select_1') == "person 1")$emails[0]->to = 'foobar1@gmx.de';
if(JRequest::getVar('select_1') == "person 2")$emails[0]->to = 'foobar2@gmx.de';
if(JRequest::getVar('select_1') == "person 3")$emails[0]->to = 'foobar3@gmx.de';



The Email Fields are enabled and the form is published.
What I do wrong?


-edit-

I saw, that in the other thread you had little dots after "->to".
But above there arent any of them.

Is it your purpose?

Greetz


-edit2-

When I fill out the form and submit, everytime I get two mails.
Both mails are adressed to all three mail adresses !?
Max_admin 27 Nov, 2008
Hi Spoona,

where did you add teh code and did you add it between php tags ?

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Spoona 28 Nov, 2008
Hi,




Here I added the code.
Was it wrong?

Greetz
GreyHead 28 Nov, 2008
Hi spoona,

You must have php tags before and after the code
<?php
if(JRequest::getVar('select_1') == "person 1")$emails[0]->to = 'foobar1@gmx.de';
if(JRequest::getVar('select_1') == "person 2")$emails[0]->to = 'foobar2@gmx.de';
if(JRequest::getVar('select_1') == "person 3")$emails[0]->to = 'foobar3@gmx.de';
?>

Bob

PS Personally I prefer the switch construct here
<?php
switch (JRequest::getVar('select_1') {
    case "person 1":
        $emails[0]->to = 'foobar1@gmx.de';
        break;
    case "person 2":
        $emails[0]->to = 'foobar2@gmx.de';
        break;
    case "person 3":
        $emails[0]->to = 'foobar3@gmx.de';
        break;
}
?>
Spoona 28 Nov, 2008
Bob & Max,


you're my personal heros of the week!!!

Thanks for helping me, it just works =)


Regards from Germany - Blackforest

Spoona
Sandstone 21 Feb, 2009
I'm attempting this method and am not able to get it to work. The email keeps going to the address that I have specified in the To field under Setup Emails and not to the e-mail address I have in the php code.

How should I have my Setup Emails configured to use this method of selecting a recipient via a drop-down field?

Thanks for helping!
Max_admin 21 Feb, 2009
Hi Sandstone,

this should work fine, please show me your HTML code for the select element, your PHP code after replacing your real emails with other ones to protect them, and is this code at the onSubmit BEFORE box ?

Cheers
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Sandstone 23 Feb, 2009
Max,

Here's the select code from the form itself:
<select class="cf_inputbox validate-selection" id="select_1" size="1" {cf_multiple} name="send-to">
    <option value="">Choose Option</option>
      <option value="Doug">Doug</option>
<option value="Admin">Admin</option>
<option value="CC">CC</option>
</select>


Here is the code from the "On Submit code - before sending email:" box (with e-mails masked out):
<?php
switch (JRequest::getVar('send-to') {
    case "Doug":
        $emails[0]->to = .'****@********.com';
        break;
    case "Admin":
        $emails[0]->to = .'****@********.com';
        break;
    case "CC":
        $emails[0]->to = .'****@********.com';
        break;
}
?>


How should I have the "Setup Emails" configured?

-Doug
GreyHead 23 Feb, 2009
Hi sandstone,

You are using = ." to add the names. I think that the 'dot' is wrong,

If you want to add the name to the existing value then it needs to be comma separated. .= ,"

Bob
Sandstone 23 Feb, 2009
I forgot I had added the dots to see if I could get the script to function properly. When I remove the dots, the form is still only sent to the address listed in the Setup Emails tab. I can't get it to go to the e-mail address listed in the "On Submit code - before sending email:" box. Here's the revised code (after the dots are removed).
<?php
switch (JRequest::getVar('send-to') {
    case "Doug":
        $emails[0]->to = '****@********.com';
        break;
    case "Admin":
        $emails[0]->to = '****@********.com';
        break;
    case "CC":
        $emails[0]->to = '****@********.com';
        break;
}
?>


Can someone tell me how I should have the "Setup Emails" tab configured when using this method?
GreyHead 23 Feb, 2009
Hi Sandstone,

You are also missing a ')' on the switch line

Bob
Sandstone 24 Feb, 2009
Ah...thank you! That's what I get for cut-n-pasting code without checking it for errors.🙂

Here is the corrected code for anyone that may want to use it in the future:
<?php
switch (JRequest::getVar('select_1')) {
    case "person 1":
        $emails[0]->to = 'foobar1@gmx.de';
        break;
    case "person 2":
        $emails[0]->to = 'foobar2@gmx.de';
        break;
    case "person 3":
        $emails[0]->to = 'foobar3@gmx.de';
        break;
}
?>


Thanks for the help!
This topic is locked and no more replies can be posted.