27 function __construct($caption, $name, $multi=0, $selected = null){
30 $this->_multi = $multi;
31 $this->_selected = $selected!=null ? (is_array($selected) ? $selected : array($selected)) : null;
39 $this->_rows = $value;
56 public function addOption($value, $caption, $select=0, $disabled=
false, $style=
''){
58 $rtn[
'value'] = $value;
59 $rtn[
'text'] = $caption;
60 $rtn[
'select'] = isset($_REQUEST[$this->
getName()]) && $_REQUEST[$this->
getName()]==$value ? 1 : $select;
61 $rtn[
'disabled'] = $disabled;
62 $rtn[
'style'] = trim($style);
63 $this->_options[] =
$rtn;
72 $rtn[
'value'] = is_array($v) && isset($v[
'value']) ? $v[
'value'] : $k;
73 $rtn[
'text'] = is_array($v) && isset($v[
'text']) ? $v[
'text'] : $v;
74 $rtn[
'select'] = isset($_REQUEST[$this->
getName()]) && $_REQUEST[$this->
getName()]==
$rtn[
'value'] ? 1 : (is_array($v) && isset($v[
'select']) ? 1 : (is_array($this->_selected) && in_array(
$rtn[
'value'], $this->_selected) ? 1 : 0));
75 $rtn[
'disabled'] = is_array($v) && isset($v[
'disabled']) ? $v[
'disabled'] : 0;
76 $rtn[
'style'] = is_array($v) && isset($v[
'style']) ? trim($v[
'style']) :
'';
77 $this->_options[] =
$rtn;
84 foreach ($this->_options as $k => $v){
85 if ($v[
'value']==$index){
86 $this->_options[$k][
'select'] = 1;
103 $rtn =
"<select name='".$this->getName().
"' id='".$this->
id().
"'";
104 if ($this->_multi){
$rtn .=
" multiple='multiple' size='".$this->_rows.
"'"; }
107 $rtn .=
'class="'.$this->getClass().
'" '.$this->
getExtra();
114 foreach ($this->_options as $k => $v){
115 $rtn .=
"<option value='$v[value]'";
116 if ($v[
'select'] || (is_array($this->_selected) && in_array($v[
'value'], $this->_selected))){
$rtn .=
" selected='selected'"; }
117 if ($v[
'disabled']){
$rtn .=
" disabled='disabled'"; }
118 if ($v[
'style']!=
'')
$rtn .=
" style='$v[style]'";
119 $rtn .=
">$v[text]</option>";