 |

Janet
User
Jul 16, 2008, 2:02 PM
Post #1 of 7
(1281 views)
Shortcut
|
|
Drop down menu
|
Can't Post
|
|
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
|
|
|  |
 |

Dave
Staff
/ Moderator

Jul 16, 2008, 11:01 PM
Post #2 of 7
(1240 views)
Shortcut
|
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
|
|
|  |
 |

Janet
User
Jul 17, 2008, 6:07 PM
Post #3 of 7
(1225 views)
Shortcut
|
Hey Dave - do you ever sleep? Thanks again for your quick response. Your code worked great once I realized my mistake. I use Dreamweaver in conjunction with CMS Builder so when I created the menu I used the "List Menu" format. Time for a vacation. Here's the snippet I ended with: In the head tags: <script type="text/javascript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> Inside the body tag: <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)"> <option>Select Semester</option> <?php foreach ($listRows as $record): ?> <?php if (@$lastSemester == $record['category_name']) { continue; } // skip this one $lastSemester = $record['category_name']; // keep track of last seen semester ?> <option value="coursesList.php?category=<?php echo $record['category_name'] ?>"> <?php echo $record['category_name'] ?> </option> <?php endforeach ?> </select> I strayed a little from your code and set up a separate section edition for "Semesters." Next time, I'm going to try it using a list field in the article editor, your code and the right Dreamweaver code for jump menu. This is a win-win. My client is getting a cool site, she's loving how easy it is to enter content, I'm loving how much I can customize it PLUS I think I'm learning a little PHP. The page isn't perfect yet - I'm still tweaking but here it is: http://www.uga.edu/dev/ecology/coursesList.php?category=Fall%202008 Thanks again! Jan
|
|
|  |
 |

Dave
Staff
/ Moderator

Jul 18, 2008, 2:19 PM
Post #4 of 7
(964 views)
Shortcut
|
Janet, Looks great! Thanks for posting back and sharing the url with us! :) Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

Donna
Staff
/ Moderator

Jul 18, 2008, 5:01 PM
Post #5 of 7
(927 views)
Shortcut
|
Little known fact: Dave is actually a robot we keep chained to his desk... ;) Donna
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

Janet
User
Jul 18, 2008, 5:09 PM
Post #6 of 7
(926 views)
Shortcut
|
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.
|
|
|  |
 |

gkornbluth
User
Jul 20, 2008, 12:51 PM
Post #7 of 7
(887 views)
Shortcut
|
I concur about the support... And your site does look really good. Jerry Kornbluth
|
|
|  |
|