} else { if ($_POST['submit'] == 'Reverse') { // *** Reverse these $to = $_POST['convertFrom']; $from = $_POST['convertTo']; // *** This is for the dropdown if (isset($_POST['convertFrom'])) { $toKey = $_POST['convertFrom']; } // *** This is for the dropdown if (isset($_POST['convertTo'])) { $fromKey = $_POST['convertTo']; } } } $convertObj = new CurrencyConvert(); $result = $convertObj->currencyConvert($amount, $from, $to); } // *** Make dropdowns $fromSelect = dropdown($selectArray, $fromKey); $toSelect = dropdown($selectArray, $toKey); function dropdown($assocArray, $selectedId = 0, $addBlank = false) { $HTMLOptions = ''; if ($assocArray) { if ($addBlank) { $HTMLOptions = '<option></option>'; } foreach ($assocArray as $id => $name) { $selected = ''; if ($selectedId == $id && $selectedId != '') {
<?php /* * Author: Jarrod Oberto * Date: Jun 2011 * Version: 1.0 * * =================================================================== * This is a demo file to help you get started * It shows the code for the online demo * =================================================================== * */ // *** Enable these when in development //ini_set('display_errors',1); //error_reporting(E_ALL | E_STRICT); include "currency_convert_class.php"; $result = ''; //print_r($_REQUEST); // *** If form submitted if (isset($_REQUEST['amt']) && $_REQUEST['currency'] != '') { $amount = $_REQUEST['amt']; $from = $_REQUEST['currency']; $to = "USD"; //$to = $_REQUEST['currency']; $convertObj = new CurrencyConvert(); $result = $convertObj->currencyConvert($amount, $from, $to); echo $result; }