php - Using JavasScript Onclick function to toggle visibility twice -
my code:
<div> <a href="/forms/login-form.php" onclick="toggle_visibility('login-div'); return false;">login</a> <div id="login-div"> <?php include($_server['document_root'].'/forms/login-form.php');?> </div> <a href="/forms/signup-form.php" onclick="toggle_visibility('signup-div'); return false;">sign up</a> <div id="signup-div"> <?php include($_server['document_root'].'/forms/signup-form.php');?> </div> <script type="text/javascript"> <!-- function toggle_visibility(id) { var e = document.getelementbyid(id); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } //--> </script> </div>
problem: login link works javascript onclick function , signup link nothing. although, when removed login link , div, signup works. therefore can mean there problem way using javascript function.
apparently cant use same javascrit function twice. tried adding function same functionality different name ie(toggle_visibility2) still first login link working toggle.
if true, how accomplish getting both links toggle js
the problem included display none in forms div:
<div id="hasjavascript" style="display: none"> form code.... </div>
the fix:
<div id="hasjavascript"> form code.... </div>
Comments
Post a Comment