22
22
class CTextBox extends CTag
27
27
function CTextBox($name='textbox',$value="",$size=20,$readonly="no")
29
$this->caption = null;
29
30
parent::CTag('input','no');
31
$this->tag_body_start = '';
30
32
$this->options['class'] = 'biginput';
31
$this->options['name'] = $name;
32
$this->options['size'] = $size;
33
$this->options['value'] = $value;
33
$this->AddOption('name', $name);
34
$this->AddOption('size', $size);
35
$this->AddOption('value',$value);
34
36
$this->SetReadonly($readonly);
36
38
function SetReadonly($value='yes')
66
class CNumericBox extends CTextBox
68
function CNumericBox($name='number',$value='0',$size=20,$readonly="no",$allowempty=false)
70
parent::CTextBox($name,$value,$size,$readonly);
71
$this->AddOption('MaxLength', $size);
72
$this->AddOption('Style', 'text-align: right;');
73
$this->AddAction('OnKeyPress',
74
' var c = (window.event) ? event.keyCode : event.which;'.
75
' if(event.ctrlKey || c <= 31 || (c >= 48 && c <= 57)) return true; else return false; ');
76
$this->AddAction('OnChange',
77
($allowempty ? ' if(this.value.length==0 || this.value==null) this.value = \'\'; else ' : '').
78
' if(isNaN(parseInt(this.value))) this.value = 0; '.
79
' else this.value = parseInt(this.value);'
86
//var $ip_parts = array();
88
function CIPBox($name='ip',$value)
90
$this->ip_parts = array();
92
if(!is_array($value)) $value = explode('.', $value);
93
if(!isset($value[0])) $value[0] = 0;
94
if(!isset($value[1])) $value[1] = 0;
95
if(!isset($value[2])) $value[2] = 0;
96
if(!isset($value[3])) $value[3] = 0;
98
for($i = 0; $i < 4; $i++)
100
$this->ip_parts[$i] = new CNumericBox($name.'['.$i.']', $value[$i], 3);
103
$this->ip_parts[$i]->tag_end = '';
104
$this->ip_parts[$i]->AddAction('OnKeyDown',
105
' this.maxlength = this.getAttribute("maxlength"); '.
106
' this.oldlength = this.value.length; ');
107
$this->ip_parts[$i]->AddAction('OnKeyUp',
108
' if(this.oldlength != this.value.length && this.value.length == this.maxlength) {'.
109
' var el = this.form.elements["'.$name.'['.($i+1).']'.'"];'.
110
' if(el) { el.focus(); el.select(); }}');
112
$this->ip_parts[$i] = unpack_object($this->ip_parts[$i]);
116
function ToString($destroy=true)
118
$res = implode('.',$this->ip_parts);
122
### TODO Problem under PHP 5.0 "Fatal error: Cannot re-assign $this in ..."
129
function Show($destroy=true)
131
echo $this->ToString($destroy);