0

Hi all,

I have a div I would like to show and hide.

I've used a script before which works, but now reusing it I can't make it fly. As I can't see where I am going wrong, can anyone else help?

This is the one that works:

<!--script in head tag -->
<script type="text/javascript">
<!--
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}
// -->
</script>

<body>
<div id="positioned-element25">
<a href="#" onClick="toggleBox('login',1);">Login</a></div>
<div id="login">
  <form name="fp_login" action="prcs_login.php" method="post">
	<table>
<!-- abbreviated -->
            <tr>
                <td>
...
                                            <td>
                                           	  <input type="button" onClick="toggleBox('login',0);" value="Cancel">
                                            </td>
                                         </tr>
                                         
                                               
    </table>
</form>
</div>

...and this is the new version:

<script type="text/javascript">
<!--
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}
// -->
</script>
<body>
<div id="positioned-element25">
<a href="#" onClick="toggleBox('login',1);">Login</a></div>
    <div id="login"> 
            <?php
            include ('mailer.php');
            ?>
        </div>
...

I can't see the difference, but the top one works and not the bottom. Pointers please?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Will Gresham
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.