Populate drop down from List Field

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

By s2smedia - February 17, 2010

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

By s2smedia - February 18, 2010

perfecto!!

Re: [chris] Populate drop down from List Field

By thenetgirl - April 2, 2010

is there anything you have to put in the page header for this to work????
Patricia

www.thenetgirl.com