Click to See Complete Forum and Search --> : visibilitiy:hidden; possible to make it visible again?


mace945
September 10th, 2002, 09:03 PM
please i need help tryin to make a layer (textarea) visible again once u click on a certain link (info.411)

i am postin the code for my site can someone please take a look at the javascript at top and see what is wrong because the div (textarea) wont reappear?? thanks


<tt> <!-- starts here
<HTML>
<HEAD>
<TITLE>.:: mace ::.</TITLE>
<link rel=stylesheet type="text/css" href="style.css">
<script type=text/javascript>
function SHOWnews() {
var daMenu = document.all(newsticker).style;
visible = 'visible';
hidden = 'hidden';
if (daMenu.visibility == visible) {
daMenu.visibility = hidden;
} else {
daMenu.visibility = visible;
}
}
</script>
</HEAD>

<BODY BGCOLOR=BLACK>
<!-- bg -->
<div style="position:absolute; left:25px; top:45px; z-index:1">
<img src="e-7small.jpg">
</div>
<!-- table -->
<span style="position:absolute; left:70px; top:55px; z-index:3">
<P align=right><a href="#">home.news</a></P>
<P align=right><a href="#">info.411</a></P>
<P align=right><a href="#">locate.me</a></P>
</span>
<! -- shadow -->
<div style="position:absolute; left:71px; top:56px; z-index:2">
<P align=right><a href=#><font color="#354046"><a href=#>home.news</font></a></P>
<P align=right><a href=# onclick="SHOWnews()"><font color="#354046">info.411</font></a></P>
<P align=right><a href=#><font color="#354046">locate.me</font></a></P>
</div>
<! -- end of table -->


<!-- page content -->
<.:original production:.mace.:9'10'2k2:.<BR>
<form name=form1><textarea class="newsticker" cols="30" rows="4" style="position:absolute; top:55px; right: 60px; z-index:11;" frameborder="0"></textarea>
</form>


<! -- banner -->
<img src=banner.gif style="position:absolute; left:0px; top:-2px; z-index:3">
<img src=banner.gif style="position:absolute; left:0px; bottom:-2px; z-index:3">
</body>
</HTML>
</tt>

Zvona
September 11th, 2002, 02:59 AM
<script type=text/javascript>
<!--
function SHOWnews(oObj)
{
oObj.style.visibility = (oObj.style.visibility == "hidden")?"visible":"hidden";
}
// -->
</script>
.
.
<textarea id="myTextArea" cols="50" rows="10"></textarea>
.
.

<input type="button" value="show/hide textarea" onclick="SHOWnews(document.getElementById('myTextArea'));" />

mace945
September 11th, 2002, 10:00 PM
THANK YOU......ive been <!--

function SHOWnews(oObj)
{
oObj.style.visibility = (oObj.style.visibility == "visible")?"hidden":"visible";
}
// -->tryin really hard...

WORKS!!!! but why would u use oObj??
oh and when u state an arguement like above:
oObj.style.visibility = (oObj.style.visibility == "visible")?"hidden":"visible";

how would u explain that? does the "?" mean that on the next function call it would turn into "hidden": then the call after that it would turn into "visible"?

thanks alot

Zvona
September 12th, 2002, 01:55 PM
Originally posted by mace945
THANK YOU......ive been <!--

function SHOWnews(oObj)
{
oObj.style.visibility = (oObj.style.visibility == "visible")?"hidden":"visible";
}
// -->tryin really hard...

WORKS!!!! but why would u use oObj??
oh and when u state an arguement like above:
oObj.style.visibility = (oObj.style.visibility == "visible")?"hidden":"visible";

how would u explain that? does the "?" mean that on the next function call it would turn into "hidden": then the call after that it would turn into "visible"?
thanks alot

oObj is the name of the parameter. We pass an object as an parameter. Thus, oObj is an instance of the HTML element. Usually, this is applied, when you have many elements using same function and called with functionName(this);. This refers to an element, which calls the function.

oObj.style.visibility = (oObj.style.visibility == "visible")?"hidden":"visible";

means same than
if (oObj.style.visibility == "visible")
oObj.style.visibility = "hidden";
else
oObj.style.visibility = "visible";

In clear words : If an object is visible, then we set it's visibility to hidden. Otherwise, we set visibility to visible.