<?php
class Select
{
////////////////////////////////////////////////////
// Copyright (C) 2002, BigProf Software. //
// http://www.bigprof.com //
// //
// Feel free to use and modify this script but //
// kindly leave this copyright notice unmodified. //
////////////////////////////////////////////////////
////////////////////////////////////////////////////
//
// WHAT IS THIS?
////////////////
// The Select class renders a drop down select
// filled with elements in an array ListItem[]
// and associates each element with values from
// an array ListData[], and optionally selects
// one of the items.
//
// EXAMPLE:
///////////
// http://www.bigprof.com/free-php-scripts/select.php
/////////////////////////////////////////////////////////////
var $ListItem, // array of items displayed in the Select
$ListData, // array of items values
$Class, // optional CSS class name to apply to the menu
$Style, // optional CSS style to apply to the menu
$SelectName, // name of the generated menu
$SelectedData, // optional value of item to choose
$HTML; // used to output the select code
function Select() // Constructor function
{
$this->Class = "";
$this->HTML = "";
}
function Render()
{
$ArrayCount = count($this->ListItem);
if($ArrayCount > count($this->ListData))
{
$this->HTML .= "Invalid Class Definition";
return 0;
}
$this->HTML .= "<select name='$this->SelectName' class='$this->Class' style='$this->Style'>";
for($i = 0; $i < $ArrayCount; $i++)
{
if($this->SelectedData == $this->ListData[$i])
$sel = "selected class=SelectedOption";
else
$sel = "class=$this->Class";
$this->HTML .= "\n\t<option value='" . $this->ListData[$i] . "' $sel>" . $this->ListItem[$i] . "</option>";
}
$this->HTML .= "</select>";
return 1;
}
}
?>