Drop down menu

7 posts by 4 authors in: Forums > CMS Builder
Last Post: July 20, 2008   (RSS)

By Janet - July 16, 2008

I have created a "courses" list page (http://www.uga.edu/dev/ecology/coursesList.php). I only set up one section editor but I included a field called "semester" where I listed Fall 2008, Spring 2009, Summer 2009...etc.

What I wanted to include on my "courses" list page is a drop down menu populated by the [semester] field.

This code populates the drop down menu:

<form method="get" action="coursesList.php">
<select name="Semester">
<?php foreach ($listRows as $record): ?>
<option value="<?php echo $record['semester'] ?>"> <?php echo $record['semester'] ?> </option>
<?php endforeach ?> </form>

but I don't know how to limit the results to one (right now it lists Fall 2008 as many times as there are records) and I don't know how to tell the code to show only "Fall 2008" courses when selected, "Spring 2009" courses when selected, etc.

Can this be done?

Jan

Re: [Janet] Drop down menu

By Dave - July 17, 2008

It's not a feature of CMS Builder, no, but it can be done with a little bit of custom programming. Try adding the code in red:

<form method="get" action="coursesList.php">
<select name="Semester">
<?php foreach ($listRows as $record): ?>
<?php
if (@$lastSemester == $record['semester']) { continue; } // skip this one
$lastSemester = $record['semester']; // keep track of last seen semester
?>

<option value="<?php echo $record['semester'] ?>"> <?php echo $record['semester'] ?> </option>
<?php endforeach ?>
</form>


Let me know if that works for you! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Janet] Drop down menu

By Dave - July 18, 2008

Janet,

Looks great! Thanks for posting back and sharing the url with us! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Janet] Drop down menu

By Donna - July 18, 2008

Little known fact: Dave is actually a robot we keep chained to his desk...

;)
Donna

--
support@interactivetools.com

Re: [Donna] Drop down menu

By Janet - July 18, 2008

That not little known - everyone out here building sites using your software think you all live at your desks. You guys offer the best support on the planet.

Re: [Janet] Drop down menu

By gkornbluth - July 20, 2008

I concur about the support...

And your site does look really good.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php