 <p>As @user3237539 pointed out, your jQuery selectors must begin with '#'. Your code should look like this:</p> <pre><code>&lt;script type="text/javascript"&gt; function opt_onchange() { if (document.getElementById("opt").value == "") { document.getElementById("submit").style.visibility = "hidden"; } else { document.getElementById("submit").style.visibility = "visible"; } if (document.getElementById("opt").value == "banscan") { $("#form_username").fadeOut(); $("#form_password").fadeOut(); } else { $("#form_username").fadeIn(); $("#form_password").fadeIn(); } } &lt;/script&gt; </code></pre> <p>Hope that helps!</p> <p>PS: Whenever you use <code>document.getElementById()</code> you could instead use <code>$("#id")</code> to be able to use more of jQuery's helpful functions. You could replace <code>document.getElementById("submit").style.visibility = "hidden";</code> with <code>$("#submit).hide();</code></p>