OK, now when you submit the form it will get validated by js and redirected.
There's a fall back with PHP as well if you want it.
PHP Code:
<?php
error_reporting (E_ALL ^ E_NOTICE);
if ($_POST['redirect']) {
if (isset($_POST['merchant']) && !empty($_POST['merchant'])) {
$directTo = $_POST['merchant'];
header("location:".$directTo);
}
else {
echo "Sorry, you did not make a selection.";
}
}
?>
<html>
<head>
<script>
function validate(form) {
if (document.form.merchant.value == "") {
alert("You did not make a selection");
return false;
}
var directTo = document.form.merchant.value;
window.location=directTo;
}
</script>
</head>
<body>
<form method="post" action="" name="form" onsubmit="return validate(this);">
<fieldset>
Redirect: <select name="merchant">
<option value="" selected="yes">Please select</option>
<option value="https://www.amazon.com">amazon</option>
<option value="https://www.ebay.com">ebay</option>
<option value="https://www.bestbuy.com">bestbuy</option>
</select>
<br />
<input type="submit" name="redirect" value="Submit" />
</fieldset>
</form>
</body>
</html>