UISelect改为使用array传递选项,并提供一步函数create_select
This commit is contained in:
parent
6d2475fd51
commit
f026e7e5ce
@ -4,17 +4,13 @@
|
|||||||
{
|
{
|
||||||
private $name;
|
private $name;
|
||||||
private $selected;
|
private $selected;
|
||||||
|
private $items;
|
||||||
|
|
||||||
public function __construct1($n)
|
public function __construct($n,$s,$i)
|
||||||
{
|
|
||||||
$this->name=$n;
|
|
||||||
$this->selected=null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __construct2($n,$s)
|
|
||||||
{
|
{
|
||||||
$this->name=$n;
|
$this->name=$n;
|
||||||
$this->selected=$s;
|
$this->selected=$s;
|
||||||
|
$this->items=$i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function SetSelected($s)
|
public function SetSelected($s)
|
||||||
@ -22,12 +18,11 @@
|
|||||||
$this->selected=$s;
|
$this->selected=$s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function start()
|
public function out_html()
|
||||||
{
|
{
|
||||||
echo '<select name="'.$this->name.'">';
|
echo '<select name="'.$this->name.'">';
|
||||||
}
|
|
||||||
|
|
||||||
public function option($value,$text)
|
foreach($this->items as $value=>$text)
|
||||||
{
|
{
|
||||||
if($this->selected==$value)
|
if($this->selected==$value)
|
||||||
echo '<option value="'.$value.'" selected="selected">'.$text.'</option>';
|
echo '<option value="'.$value.'" selected="selected">'.$text.'</option>';
|
||||||
@ -35,9 +30,15 @@
|
|||||||
echo '<option value="'.$value.'">'.$text.'</option>';
|
echo '<option value="'.$value.'">'.$text.'</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function end()
|
|
||||||
{
|
|
||||||
echo '</select>';
|
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