0
我正在調用一個函數onclick事件select_(argum);
無論我傳遞什麼值它都會在控制檯中顯示未捕獲的引用錯誤。如果我通過登錄或註冊其是跨度元件的ID然後將其傳遞ObjectHtmlSpanElement在函數中傳遞的參數顯示未捕獲的引用錯誤
<form method="post">
<span id="login" onClick="select_(abcd);">LOGIN</span>|<span id="signup" onClick="select_(sign)">SIGNUP</span>
<div id="login_form">
<table>
<tr>
<td><input type="email" name="login_email" placeholder="Email" /></td>
</tr>
<tr>
<td><input type="password" name="login_password" placeholder="Password" /></td>
</tr>
</table>
</div>
<div id="signup_form">
<table>
<tr>
<td><input type="text" name="fname" placeholder="First Name" /></td>
</tr>
<tr>
<td><input type="text" name="lname" placeholder="Last Name" /></td>
</tr>
<tr>
<td><input type="email" name="login_email" placeholder="Email" /></td>
</tr>
<tr>
<td><input type="password" name="login_password" placeholder="Password" /></td>
</tr>
<tr>
<td><input type="password" name="confirm_login_password" placeholder="Confirm Password" /></td>
</tr>
</table>
</div>
</table>
<a href="<?php echo $fb_loginUrl;?>" ><img id="facebook" src="img/fblogin.png" /></a>
<a href="<?php echo $authUrl;?>"><img id="google" src="img/signin_button.png" /></a><br>
</form>
</body>
<script>
function _(id){
return document.getElementById(id);
}
function select_(tabs){//Pass name of selected tab
alert(tabs);
if(tabs == "abcd"){
_("login_form").style.display = "block";//Display Login form
_("signup_form").style.display = "none";//Hides Signup Form
}
else{
_("login_form").style.display = "none";//Hide Login Form
_("signup_form").style.display = "block";//Display Signup Form
}
}
</script>