Will Bagshaw Will Bagshaw - 1 year ago 80
Javascript Question

Javascript redirect to two thank you pages, depending on form response

There is a yes or no field on the form, depending on user's choice I would like to send them to a different thank you page depending on their answer.

With this, I just get a blank page. I've tried everything I can think of, so I appreciate any insight.

<form action="http://www.google.com/form" name="Lead" id="Lead" class="sem-form" onsubmit="return redirectTY()">

<label class="select">
<select name="Invest_RD" id="Invest_RD">
<option value="Yes">Yes</option>
<option selected="selected" value="No">No</option>

function redirectTY(){
var qualify = document.getElementById("Invest_RD".value);
if (qualify == "Yes"){
} else {

Answer Source

Your code looks fine, except for this detail:


This will crash all your javascript. Probably your console (developer tools) have red messages refered to this. To fix it write:


That's because getElementById() is a method of document, and value is a property of the element returned by getElementById().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download