Basic jQuery SHOW (if/else) almost working, syntax help
OVERVIEW
Prototyping a page for client, who wants validation on a specific select option. Wants this validation to occur on submit of page.
I am using jQuery SHOW function if select option specific index = true, If index = false, then go to some other page.
The SHOW function works on the IF portion (desired option value = true)
But then immediately fires the ELSE portion (go to some other page)
HEAD
-
<script language="javascript" type="text/javascript">
$(document).ready(function() {
//validate if select option = other
$("a#btn_update").click(function() {
if (document.myform.myselect.options[4].selected == true) {
$("div#error_wrap").show("slow");
};
else (document.myform.myselect.options[4].selected == false); {
window.location.href = "http://www.google.com";}
return true;
});
});
</script>
HTML
-
<div>
<ul>
<li>Reason:</li>
<li>
<form action="#" method="post" name="myform">
<select name="myselect" id="myselect">
<option value="0">Select...</option>
<option value="1">Reason 1</option>
<option value="2">Reason 1</option>
<option value="3">Reason 1</option>
<option value="4">Other</option>
</select>
</form>
</li>
</ul>
</div>