PDA

View Full Version : Using a dropdown menu


Switch17
08-14-2002, 01:28 PM
First, let me thank Spookster for his earlier help. Adding max to my query solved that problem and all my menu's work well now. Guess I could just change the the number each week as well in stead of adding new rows. Now on to my next task/problem, which is calling my team pages.

Basically, I'm setup so that currently every report/webpage such as the index, etc, 'call's' the menu's into their page from a separate report called vertical_menu.php. Now, I'm looking to include a dropdown menu box in that menu file that includes all of my teams. I'm not sure how to set this up using php. Heres a piece/section of the vertical menu file as it currently stands.


<a href="<? echo ($FL[18].$options); ?><span class=box2>Past Champions</span></a>


<span class=box1>&nbsp;2002 Team Pages</span>
<FORM>
<INPUT NAME="Range" TYPE="hidden" VALUE="Any"><INPUT NAME="Format" TYPE="hidden" VALUE="Standard">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" class="change">
<option selected>Teams</option>
<option value="<a href="<? Team_Page_1.php; ?>">Test Page</option>
</select></form>

<a href="<? echo ($FL[20].$options); ?><span class=box2>MFL Schedule</span></a>

If you really look at it, reports #18 and $20 are actually variables I've assigned elsewhere to customise the report numbers by week, but the team pages will always use the same file name, so I think I shoud be able to define the file name right here, but what I'm unsure of is how to place the php file inside the form menu box.

Thanks again for everyone's help here.
Switch

mordred
08-14-2002, 02:17 PM
I might be misunderstanding you, but can your task be simplified to this phrase "I want to populate my HTML select list from an external file"?

If so, I would propose a slightly different approach:

Create an array that stores the teams. Or, write it line-by-line to a text file and get its contents by using the function file().

Put that array into a function. Call that function sth like writeTeamsSelectList(). In that function, you loop through the array like this (quasi-code, not tested):


$output = "";

for ($i = 0; $i < count($teams); $i++) {
$output .= '<option value="' . $teams[$i] . '">' . . $teams[$i] . "</option>\n";
}

echo $output;


And then, within your menu template code, just insert the function call:


<select name="menu1" onChange="MM_jumpMenu('parent',this,0)" class="change">
<option selected>Teams</option>
<?php writeTeamsSelectList(); ?>
</select>


The idea of this is to make a seperation between business logic and it's presentation. If you want to add have more text within the option tags, you only have to adjust the looping procedure once and all that code can lie peacefully in an external file.

Well, a rough sketch I admit. But perhaps it helps you anyway. :)

Switch17
08-16-2002, 11:20 PM
Thanks for the response mordrid. I new with PHP, but think I get what you mean, and that sounds like it should work. I'll give it a shot, and let you know it goes.