Forums

Multiple Selections sent in Email Template

mangotti 01 Jul, 2008
Hello,

I created a new form and have a few areas where the questions have a lsit box where you can select more than one answer. Shown below:
What activities did your child(ren) like best? (select all that apply)<br/>
<select name="Favorite_Activities" multiple="" size="7">
  <option value="Craft Tent">Craft Tent</option>
  <option value="Recycled Crafts">Recycled Crafts</option>
  <option value="Reptile Exhibit">Reptile Exhibit</option>
  <option value="Inflatable Slide">Inflatable Slide</option>
  <option value="Trackless Train">Trackless Train</option>
  <option value="Small Bounce">Small Bounce</option>
  <option selected="" value="Pony Rides">Pony Rides</option>
</select>


Now, typically I would make my email template like so:
24. What activities did your child(ren) like best? <b>{Favorite_Activities}</b><br />


This will not give me the results if more than one item is selected. What do I need to do to show all items selected in the email template? Thanks.
GreyHead 02 Jul, 2008
Hi Mangotti,

Make the field name into an array name[code]name="field_name[]"/code] and then it will keep multiple values. There are some posts here on the forums about un-packing and displaying these - search on 'Sofia' if my memory serves me correctly.

Bob

Late, sorry, fixed a couple of typos in there.
mangotti 02 Jul, 2008
Okay. I changed the form to look like this:
What activities did your child(ren) like best? (select all that apply)<br/> <select name=Favorite_Activities[] multiple="" size="7"> 
 <option value="Craft Tent">Craft Tent</option>  
<option value="Recycled Crafts">Recycled Crafts</option>  
<option value="Reptile Exhibit">Reptile Exhibit</option>  
<option value="Inflatable Slide">Inflatable Slide</option> 
 <option value="Trackless Train">Trackless Train</option>  
<option value="Small Bounce">Small Bounce</option>  
<option selected="" value="Pony Rides">Pony Rides</option> 
</select>
I tested the form and I did not get the correct results.

I searched for 'Sofia" but did not find what I was looking for. I'll search again.
mangotti 02 Jul, 2008
I feel stupid. I left out the quotes. This is what I'm using now.
What activities did your child(ren) like best? (select all that apply)<br/> <select name="Favorite_Activities[]" multiple="" size="7"> 
<option value="Craft Tent">Craft Tent</option> 
<option value="Recycled Crafts">Recycled Crafts</option> 
<option value="Reptile Exhibit">Reptile Exhibit</option> 
<option value="Inflatable Slide">Inflatable Slide</option> <option value="Trackless Train">Trackless Train</option> 
<option value="Small Bounce">Small Bounce</option> 
<option selected="" value="Pony Rides">Pony Rides</option> 
</select>
Works so far.
GreyHead 02 Jul, 2008
Hi magotti,

The code you need to display or save this is
<?php
$_POST['field_name'] = implode(', ', $_POST['field_name']);
?>
This will covert the array into a comma separated string.

Bob
mangotti 02 Jul, 2008
Inserting the code you recommended in the OnSubmit area?

Currently it is not there but my email template is returning the results with commas. Do I still need to add the POST code?
GreyHead 02 Jul, 2008
Hi magotti,

If it's working then leave it alone, don't change anything

Bob
mangotti 02 Jul, 2008
Great. Thanks. As always you are very helpful!🙂
This topic is locked and no more replies can be posted.