inside your function toggleTable
when you do this line
document.getElementById("loginLink").onclick = toggleTable(....
you are actually calling the function again. so toggleTable
gets called again, and again and again, you're falling in an infinite recursive call.
make it simple.
function toggleTable()
{
var elem=document.getElementById("loginTable");
var hide = elem.style.display =="none";
if (hide) {
elem.style.display="table";
}
else {
elem.style.display="none";
}
}
see this fiddle