UISelect改为使用array传递选项,并提供一步函数create_select
This commit is contained in:
parent
6d2475fd51
commit
f026e7e5ce
@ -4,17 +4,13 @@
|
||||
{
|
||||
private $name;
|
||||
private $selected;
|
||||
private $items;
|
||||
|
||||
public function __construct1($n)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=null;
|
||||
}
|
||||
|
||||
public function __construct2($n,$s)
|
||||
public function __construct($n,$s,$i)
|
||||
{
|
||||
$this->name=$n;
|
||||
$this->selected=$s;
|
||||
$this->items=$i;
|
||||
}
|
||||
|
||||
public function SetSelected($s)
|
||||
@ -22,22 +18,27 @@
|
||||
$this->selected=$s;
|
||||
}
|
||||
|
||||
public function start()
|
||||
public function out_html()
|
||||
{
|
||||
echo '<select name="'.$this->name.'">';
|
||||
}
|
||||
|
||||
public function option($value,$text)
|
||||
{
|
||||
if($this->selected==$value)
|
||||
echo '<option value="'.$value.'" selected="selected">'.$text.'</option>';
|
||||
else
|
||||
echo '<option value="'.$value.'">'.$text.'</option>';
|
||||
}
|
||||
foreach($this->items as $value=>$text)
|
||||
{
|
||||
if($this->selected==$value)
|
||||
echo '<option value="'.$value.'" selected="selected">'.$text.'</option>';
|
||||
else
|
||||
echo '<option value="'.$value.'">'.$text.'</option>';
|
||||
}
|
||||
|
||||
public function end()
|
||||
{
|
||||
echo '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
function create_select($n,$s,$i)
|
||||
{
|
||||
$ui=new UISelect($n,$s,$i);
|
||||
|
||||
$ui->out_html();
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user