2016-08-21 23:06:17 +04:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class UISelect
|
|
|
|
|
{
|
|
|
|
|
private $name;
|
|
|
|
|
private $selected;
|
2016-08-31 01:30:18 +04:00
|
|
|
|
private $items;
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
2016-08-31 01:30:18 +04:00
|
|
|
|
public function __construct($n,$s,$i)
|
2016-08-21 23:06:17 +04:00
|
|
|
|
{
|
|
|
|
|
$this->name=$n;
|
|
|
|
|
$this->selected=$s;
|
2016-08-31 01:30:18 +04:00
|
|
|
|
$this->items=$i;
|
2016-08-21 23:06:17 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function SetSelected($s)
|
|
|
|
|
{
|
|
|
|
|
$this->selected=$s;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-31 01:30:18 +04:00
|
|
|
|
public function out_html()
|
2016-08-21 23:06:17 +04:00
|
|
|
|
{
|
|
|
|
|
echo '<select name="'.$this->name.'">';
|
|
|
|
|
|
2016-08-31 01:30:18 +04:00
|
|
|
|
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>';
|
|
|
|
|
}
|
2016-08-21 23:06:17 +04:00
|
|
|
|
|
|
|
|
|
echo '</select>';
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-31 01:30:18 +04:00
|
|
|
|
|
|
|
|
|
function create_select($n,$s,$i)
|
|
|
|
|
{
|
|
|
|
|
$ui=new UISelect($n,$s,$i);
|
|
|
|
|
|
|
|
|
|
$ui->out_html();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-08-21 23:06:17 +04:00
|
|
|
|
?>
|