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 != '') { $selected = 'selected="selected"';