Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Divs? 1

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
0
0
GB
Hi,

Been trying to use javascript to hide a div in a page after its been processed.
I've searched around and seen a number of methods, none of which seem to work for me including:

document.all["DIVNAME"].style.visibility = 'hidden';
document.all["DIVNAME"].style.display = 'none';

document.layers('DIVNAME').style.visibility = 'hidden';

I've tried placing these into a javascript function and running the function from ASP; it enters the function, just doesn't hide the divs.

Any tips on what I could do?
Thanks.

Maldini
 
1. give your div an ID. [tt]<div id="myDiv">[/tt].
2. avoid using the "all" collection at all costs.
[tt] document.getElementById('myDiv').style.display = 'none';[/tt]

3. "running the function from ASP". que? this would need to run from JavaScript.

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks for the quick reply.
My divs already had names, but it still didn't work.

This is what I've got:

<SCRIPT language="JavaScript">

function hide_div() {
alert('In function');
document.getElementById('breadcrumb').style.display = 'none';
document.getElementById('breadcrumb').style.visibility = 'hidden';
}
</SCRIPT>


and this is ASP:

<%
If Request("REQUEST_METHOD") = "POST" Then
Response.Write "<script type='text/javascript'>hide_div();</script>"
End If
%>

and in HTML:

<div id="breadcrumb">
Main Site :: Sister Site :: Admin
</div>

I'm just trying to hide the Div 'breadcrumb' when a form is posted back, but everything happens apart from the hiding.

Thanks again.

Maldini
 
you'll need to call the function AFTER the div is written to the browser. try putting that code at the bottom of the page.

although, why don't you just do this:

Code:
    <div id="breadcrumb"
<%
If Request("REQUEST_METHOD") = "POST" Then
    Response.Write  "style='display: none;'"
End If
%>
    >
        Main Site :: Sister Site :: Admin
    </div>

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks, I never thought it was the positioning that caused the problem. Now I can continue developing other parts.

Thanks again.

Maldini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top