I am trying to grab all selected items in the following select multiple and separate them by a comma. The code is below:
<select id="ps-type" name="ps-type" multiple="multiple" size="5">
<option>Residential - Wall Insulation</option>
<option>Residential - Attic /Crawl Space Insulation</option>
<option>Residential - Foundation Insulation</option>
<option>Residential - Exterior Roof System</option>
<option>Commercial - Wall Insulation</option>
<option>Commercial - Air Barrier System (Walltite)</option>
<option>Commercial - Roof System</option>
</select>
The result I am looking for is the following:
Residential - Wall Insulation, Commercial - Wall Insulation, ...
Try this:
Add the values to an array and use
join
to create the string: