PDA

View Full Version : "this" question


Antoniohawk
03-19-2003, 10:10 PM
I was wondering how to make the following into true javascript code. I have a couple <div>'s. I was wondering how i could make it so that when 1 is clicked its z-index is greater than any of the others, putting it on top. I know this is possible because i have seen it done. The only prob is that i dont know how to do it. Any help would be greatly appreciated. Thank You in advance.

beetle
03-19-2003, 10:40 PM
Well, the real problem here is not giving selected DIV a new z-index, but resetting/lowering that of all the others.

Or, employing some method so that the clicked div always get's the highest. Something like this is pretty simple and has drawbacks in certain situations, but it works<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>To top</title>
<meta name="Generator" content="TextPad 4.4" />
<meta name="Author" content="Peter Bailey" />

<style type="text/css">
div {
position: absolute;
width: 200px;
height: 200px;
border: 1px solid #999;
background-color: #DDD;
}
div#one {
left: 100px;
top: 30px;
z-index: 1;
}
div#two {
left: 30px;
top: 120px;
z-index: 1;
}
div#thr {
left: 180px;
top: 80px;
z-index: 1;
}
</style>
<script type="text/javascript">

function toTop( elem )
{
if ( !toTop.zIndex ) toTop.zIndex = 5;
elem.style.zIndex = ++toTop.zIndex;
}

</script>
</head>

<body>
<div id="one" onclick="toTop( this )"></div>
<div id="two" onclick="toTop( this )"></div>
<div id="thr" onclick="toTop( this )"></div>
</body>
</html>

Antoniohawk
03-19-2003, 11:11 PM
This is a great script, thx alot beetle. You were right lol, there are complications. Hopefully u can help me out.

http://www.angelfire.com/games4/guidetorune/calc/hopeful.html

To the <div>'s i have added a script that minimizes them when a link is clicked. The only prob is as you can prob can see on the page is that when they are minimized i am still able to click on the invisible part of them. That probably wasnt a very good explanation, but if you look at the page and monkey with it a bit u will see what im talking about. Thx again for your help.

Antoniohawk
03-21-2003, 12:09 AM
*bump*
so that beetle can see the post and continue to help me :)

beetle
03-21-2003, 03:24 AM
replace all these

function minidata()
{
document.getElementById("idata").style.visibility = "hidden";
}
//maximizes the input data part
function maxidata()
{
document.getElementById("idata").style.visibility = "visible";
}
//minimizes the output data part
function minodata()
{
document.getElementById("odata").style.visibility = "hidden";
}
//maximizes the output data part
function maxodata()
{
document.getElementById("odata").style.visibility = "visible";
}
//minimizes the output data part
function mininfo()
{
document.getElementById("info").style.visibility = "hidden";
}
//maximizes the output data part
function maxinfo()
{
document.getElementById("info").style.visibility = "visible";
}

with this

function minimize( oId )
{
document.getElementById( oId ).style.display = "none";
}

function maximize( oId )
{
document.getElementById( oId ).style.display = "block";
}

And pass the IDs as strings when you call the function

Weirdan
03-21-2003, 03:34 PM
You can look at this sample and steal some ideas :D
Winlet sample (http://test12.cardsgate.com/samples/winlets/)

Antoniohawk
03-22-2003, 05:59 AM
thx alot for replying and continuing to help me. Beetle it looked to me like that would work, but i implememented it and got the same problem.

Antoniohawk
03-24-2003, 05:32 AM
still having the same prob beetle, i hope that you or some1 can help me