Populate drop down from List Field

5 posts by 4 authors in: Forums > CMS Builder
Last Post: April 5, 2010   (RSS)

Hi,

I have a list field for a section containing t-shirt sizes. (mutli-selection check boxes)
<?php echo join(',', getListLabels('merchandise', 'size', $merchandiseRecord['size'])); ?>

But instead of displaying the sizes( ex. S, M, L, XL ...like the above code will do)

I want them to be in a drop down list for people to select what size they want..

I know this isnt right, but something like this (this only displays the first size:

select name="Size">
<option value="Small"><?php echo join('</option>', getListLabels('merchandise', 'size', $merchandiseRecord['size'])); ?>
</select>

Re: [s2smedia] Populate drop down from List Field

By Chris - February 18, 2010 - edited: February 18, 2010

Hi s2smedia,

How about this?

<select name="Size">
<?php $options = getListLabels('merchandise', 'size', $merchandiseRecord['size']) ?>
<?php foreach($options as $option): ?>
<option><?php echo htmlspecialchars($option) ?></option>
<?php endforeach ?>
</select>


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Populate drop down from List Field

perfecto!!

Re: [thenetgirl] Populate drop down from List Field

By Donna - April 5, 2010

Hi Patricia!

Nothing specific, but this particular code will only work in a repeating foreach loop (as in a list of items), as opposed to on its own like what you're trying to do. :)
Donna

--
support@interactivetools.com