Server IP : 103.118.17.23 / Your IP : 216.73.216.188 Web Server : Microsoft-IIS/10.0 System : Windows NT RESELLERPLESK22 10.0 build 20348 (Windows Server 2016) AMD64 User : IWAM_plesk(default) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/vhosts/mesa.org.in/httpdocs/assets/_core/php/examples/basic_qform/ |
Upload File : |
<?php require_once('../qcubed.inc.php'); class CalculatorForm extends QForm { // Our Calculator needs 2 Textboxes (one for each operand) // A listbox of operations to choose from // A button to execute the calculation // And a label to output the result protected $txtValue1; protected $txtValue2; protected $lstOperation; protected $btnCalculate; protected $lblResult; // Define all the QContrtol objects for our Calculator protected function Form_Create() { $this->txtValue1 = new QTextBox($this); $this->txtValue2 = new QTextBox($this); $this->lstOperation = new QListBox($this); $this->lstOperation->AddItem('+', 'add'); $this->lstOperation->AddItem('-', 'subtract'); $this->lstOperation->AddItem('*', 'multiply'); $this->lstOperation->AddItem('/', 'divide'); $this->btnCalculate = new QButton($this); $this->btnCalculate->Text = 'Calculate'; $this->btnCalculate->AddAction(new QClickEvent(), new QServerAction('btnCalculate_Click')); $this->lblResult = new QLabel($this); $this->lblResult->HtmlEntities = false; } // Perform the necessary operations on the operands, and output the value to the lblResult protected function btnCalculate_Click($strFormId, $strControlId, $strParameter) { switch ($this->lstOperation->SelectedValue) { case 'add': $mixResult = $this->txtValue1->Text + $this->txtValue2->Text; break; case 'subtract': $mixResult = $this->txtValue1->Text - $this->txtValue2->Text; break; case 'multiply': $mixResult = $this->txtValue1->Text * $this->txtValue2->Text; break; case 'divide': $mixResult = $this->txtValue1->Text / $this->txtValue2->Text; break; default: throw new Exception('Invalid Action'); } $this->lblResult->Text = '<b>Your Result:</b> ' . $mixResult; } } // And now run our defined form CalculatorForm::Run('CalculatorForm'); ?>