<script>
document.getElementById(‘comment-form1’).addEventListener(‘submit’,(e)=>{
e.preventDefault();
window.location = (document.getElementById(‘option’).value);
})
</script>
Code for Redirect page Based on the select box while submit the form
index.php:
<head>
<title>Redirect page based on select box using javascript</title>
<style>
input, select
{
width: 280px;
margin: 19px;
height: 45 px;
padding: 10px;
}
</style>
</head>
<body>
<form id=”comment-form1″ name=”contact-form1″ onsubmit=”return mysubmit();”>
<input type=”text” name=”name” placeholder=”Your Name..” required><br>
<input type=”text” name=”email” placeholder=”Your Email..”required></br>
<input type=”text” name=”phone” placeholder=”Your 10 digit Phone..”require pattern=”[0-9]{10}”><br/>
<select id=”option” class=”chosen” >
<option selected disabled>Select Bank</option>
<option value=”http://demos.sanwebcorner.com/”>Sanwebcorner Demo</option>
<option value=”http://www.sanwebcorner.com/” >Sanwebcorner Main Page</option>
<option value=”http://www.sanwebcorner.com/2018/12/bounce-effect-on-hover-button-using-css-and-html.html” >Single page</option>
</select><br/>
<input name=”submit” type=”submit” value=”Submit” /><br>
</form>
<script>
document.getElementById(‘comment-form1’).addEventListener(‘submit’,(e)=>{
e.preventDefault();
window.location = (document.getElementById(‘option’).value);
})
</script>
</div>
</div>
</section>
</body>
</html>
Redirect Page based on select box and send form information to Admin Email Id:
if (isset($_POST[‘submit’]))
{
$to = “admin@example.com”;
$from = “admin@example.com”;
$name=$_POST[‘name’];
$email=$_POST[’email’];
$phone=$_POST[‘phone’];
$bank=$_POST[‘bank’];
$subject = “New Donation Info”;
$message = ” nn Name: “.$name.”<br/> nn Email: ” .$email.”<br/> nn Mobile: “.$phone.”<br/> Bank Name: “.$bank. “<br/> nn” ;
//$message = ” Hi this is test” ;
$headers = ‘MIME-Version: 1.0’ . “rn”;
$headers .= ‘From:Donation Info from Website:>’ . “rn”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “rn”;
mail($to,$subject,$message,$headers);
echo ‘<script>alert(“Your Enquiry Received . We will contact you soon…”);</script>’;
if($bank==”www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn”)
{
echo ‘<script>location.href = “https://www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn”</script>’;
}
elseif($bank==”netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128″)
{
echo ‘<script>location.href = “https://netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128″</script>’;
}
elseif($bank==”netbanking.canarabank.in/entry/ENULogin.jsp”)
{
echo ‘<script>location.href = “https://netbanking.canarabank.in/entry/ENULogin.jsp”</script>’;
}
}
?>
<html>
<head>
<title>Redirect page based on select box using javascript</title>
<style>
input, select
{
width: 280px;
margin: 19px;
height: 45 px;
padding: 10px;
}
</style>
</head>
<body>
<form id=”comment-form1″ name=”contact-form1″ method=”post” onsubmit=”return mysubmit();”>
<input type=”text” name=”name” placeholder=”Your Name..” required>
<input type=”text” name=”email” placeholder=”Your Email..”required>
<input type=”text” name=”phone” placeholder=”Your 10 digit Phone..”require pattern=”[0-9]{10}”>
<select name=”bank” id=”option” class=”chosen” style=”width:500px;”>
<option selected disabled>Select Bank</option>
<option value=”netbanking.hdfcbank.com/netbanking/?_ga=2.196148587.673827790.1549438128-1636006557.1549438128″>Hdfc Bank</option>
<option value=”www.icicibank.com/safe-online-banking/safe-online-banking.page?itm=nli_hp_0_btn_ib_loginbtn” >ICICI Bank</option>
<option value=”netbanking.canarabank.in/entry/ENULogin.jsp” >Canara Bank</option>
</select>
<input name=”submit” type=”submit” value=”Submit” /><br>
</form>
</div>
</div>
</section>
</body>
</html>
