Example #1
0
        }
        // If we're here, then the custom Form validation rule validated properly
        return true;
    }
    // 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');
        }
        if (isset($mixResult)) {
            $this->lblResult->Text = '<b>Your Result:</b> ' . $mixResult;
        }
    }
}
// And now run our defined form
CalculatorForm::Run('CalculatorForm');