1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php class SelectExt { var $content; var $selectedName; var $selectedValue; var $name; var $useNameAsValues; var $functArray;
var $className; var $fieldVal; var $fieldName;
function SelectExt($name, $className, $fieldVal, $fieldName, $id = "") { $this->name = $name; $this->className = $className; $this->fieldName = $fieldName; $this->fieldVal = $fieldVal;
$this->useNameAsValues = false; if($id == "") $this->id = $name; else $this->id = $id; $functArray = array(); }
function AttachArray($arr) { $this->content = $arr; }
function AddOnFunction($name, $functName) { $str = $name . " = " . "\"" . $functName . ";\""; $this->functArray[] = $str; }
function Generate() { $ret = "<SELECT NAME = \"" . $this->name . "\" id = \"" . $this->id . "\""; if(count($this->functArray) > 0) { foreach($this->functArray as $funct) $ret.=" " . $funct; } $ret.=">"; $fieldName_ = $this->fieldName; $fieldVal_ = $this->fieldVal;
foreach($this->content as $obj) { if($this->useNameAsValues == false) { $ret.="<OPTION value = \"" . $obj->$fieldVal_ . "\""; if($this->selectedValue == $obj->$fieldVal_) $ret.=" SELECTED"; } else { $ret.="<OPTION value = \"" . $obj->$fieldName_ . "\""; if($this->selectedName == $obj->$fieldName_) { $ret.=" SELECTED"; } } $ret.=" >" . $obj->$fieldName_ . "</OPTION>"; } $ret.="</SELECT>"; return $ret; } } ?>
|