Forums

How to make a multiple drop down sending a proper email?

LAMF 09 Jan, 2013
Hi,
I have made a form with 4 different multiple drop downs where I have like 6 to 20 different options to pick in each drop down.
I want the visitor to fill in their name email etc and then pick as many of the drop down choices as they wish and then just submit the form after filling the captcha code.
The mail is sent away as it should but the value sent from the drop down choices is far from my wishes.
My simple qiuestion i how do I set the drop down up to make it work with multiple choices?
My settings in one of the drop downs is:
GENERAL
Field name: oils
Field Id:
Field class:
Field title:
Label text: Choose oils
Multiple: checked
Size: 1
Selected:
Show Empty: Choose oils
Options:
1=T55 80W-90 20l
2=T55 80W-90 208l
3=T55 80W-140 20l
4=T55 80W-140 208l
5=T65 75W-90 20l
6=T65 75W-90 208l
7=T65 75W-140 20l
8=T65 75W-140 208l
9=T1000 10W-30 20l

OTHER
Label over: checked
The rest is left blank

So if anyone knows the drill please help me.

Best regards
Micke
GreyHead 10 Jan, 2013
Hi LAMF,

the value sent from the drop down choices is far from my wishes.

What are your wishes and what is happening now?

Bob
LAMF 10 Jan, 2013
Hi Bob,
The email look good but the data from the drop down if I chooce two kind of grease
looks like this:
Your choice of grease: array ( 0 => '3', 1 => '6', )

So that's what I mean with strange, I would like the name of the product in plain text.

URL to the form is:
http://www.enskedehydraul.se/okq8

Thanks
Micke
GreyHead 10 Jan, 2013
HI LAMF,

There are two ways to handle this:

a) you can change the options so that the values are meaningful e.g.
T55 80W-90 20l=T55 80W-90 20l
T55 80W-90 208l=T55 80W-90 208l
. . .
or

b) you can add Custom Code to look up the values before the email is sent
<?php
$oil_array = array(
  1 => 'T55 80W-90 20l',
  2 => 'T55 80W-90 208l'.
  . . .
);
$oil_names = array();
foreach ( $form->data['oils'] as $v ) {
  $oil_names[] = $oil_array[$v];
}
$form->data['oil_names'] = implode(', ', $oil_names);
?>
and then use {oil_names} in the email. Note that this code needs to go before any Handle Arrays action.

I think that the first method will probably work for your form; the second is more useful if the values are product codes that need to be saved or processed.

Bob
LAMF 10 Jan, 2013
Hi,
Ok i have tried this and now I get the text string for the name but it also gives the array etc. like this:

array ( 0 => 'T800 10W-40 208l', 1 => 'T750 15W-40 208l', 2 => 'Excel 5W-40 20l', )

Is it possible to only get the names like this: T800 10W-40 208l,T750 15W-40 208l,Excel 5W-40 20l,

BR
Micke
GreyHead 10 Jan, 2013
Hi Micke,

You can use the Handle Arrays action to change the array to a comma separated list.

Bob
LAMF 10 Jan, 2013
Hi Bob!
Super thanks for your help with this.
The handle arrays is great!
For others who might be interested it can also handle html so you can for example add in a ", <br>" if you want a nice new row for each item. 😀
This topic is locked and no more replies can be posted.