1: <?php
 2: require_once('../qcubed.inc.php');
 3: QApplication::$EncodingType = 'ISO-8859-1';
 4: 
 5:  6:  7:  8: 
 9: class MyControl extends QControl {
10:     public $txt;
11:     public $nullVal;
12: 
13:     public function GetControlHtml() {
14:         return $this->RenderTag('input');
15:     }
16:     public function ParsePostData() {
17:         if (isset($_POST[$this->ControlId . '_extra'])) {
18:             $this->txt = $_POST[$this->ControlId . '_extra']['txt'];
19:             $this->nullVal = $_POST[$this->ControlId . '_extra']['nullVal'];
20:         }
21:     }
22: 
23:     public function Validate() {
24:         return true;
25:     }
26: 
27:     public function GetEndScript()
28:     {
29:         $strId = $this->ControlId;
30: 
31:         $strJs = parent::GetEndScript();
32:         $strJs .= ';';
33:         $strJs .= "\$j('#{$strId}').change(function(event) {
34:             qcubed.setAdditionalPostVar('{$strId}_extra', {txt: \$j(this).val(), 'nullVal': null});
35:             qcubed.recordControlModification('{$strId}', 'Name', \$j(this).val());
36:             })";
37:         return $strJs;
38:     }
39: }
40: 
41: class ParamsForm extends QForm {
42:     protected $txtText;
43:     protected $txt2;
44:     protected $pnlTest;
45:     protected $lstCheckables;
46: 
47:     protected $btnSubmit;
48:     protected $btnAjax;
49: 
50:     protected function Form_Create() {
51:         $this->txtText = new MyControl($this);
52:         $this->txtText->Name = "Special Vals";
53: 
54:         $this->txt2 = new QTextBox($this);
55:         $this->txt2->Name = "Regular Val";
56: 
57:         $this->pnlTest = new QPanel($this);
58:         
59:         $this->pnlTest->Name = 'Result';
60: 
61:         $this->lstCheckables = new QCheckBoxList($this);
62:         $this->lstCheckables->AddItem('', '');
63:         $this->lstCheckables->AddItem('', '');
64:         $this->lstCheckables->AddItem('', '');
65:         $this->lstCheckables->AddItem('', '');
66: 
67:         $strId = $this->txtText->ControlId;
68:         $strJs = "{txt: \$j('#{$strId}').val(), nullVal:null}";
69: 
70:         $this->btnSubmit = new QButton($this);
71:         $this->btnSubmit->Text = "Server Submit";
72:         $this->btnSubmit->AddAction(new QClickEvent(), new QServerAction('submit_click', null, $strJs));
73: 
74:         $this->btnAjax = new QButton($this);
75:         $this->btnAjax->Text = "Ajax Submit";
76:         $this->btnAjax->AddAction(new QClickEvent(), new QAjaxAction('submit_click', null, null, $strJs));
77:     }
78: 
79:     protected function submit_click($strFormId, $strControlId, $mixParam) {
80:         
81:         $strResult = $this->txtText->txt;
82:         $strResult .= ($this->txtText->nullVal === null ? ' and is null' : ' and is not null');
83: 
84:         
85:         $strResult .= "\n" . var_export($mixParam, true);
86: 
87:         
88:         $checkables = $this->lstCheckables->SelectedValues;
89:         $strResult .= "\n" . var_export($checkables, true);
90:         $checkables = $this->lstCheckables->SelectedNames;
91:         $strResult .= "\n" . var_export($checkables, true);
92:         $strResult .= "\n" . 'Ordinals: ' . ord($this->txtText->Name) . ',' . ord($strResult);
93:         $strResult .= "\n" . 'Regular: ' . $this->txt2->Text;
94:         
95:         $this->pnlTest->Text = $strResult;
96:     }
97: }
98: ParamsForm::Run('ParamsForm');
99: