PDA

View Full Version : z-index



spyder
05-11-2007, 12:11 AM
i am using this code so that when i click on a dragable element, it comes to the top. how could i change it so that when i click on an object, a different object comes to the top. basicall i want to be able to hit a picture which will make a table appear.


<script language="Javascript">
<!--
last_z=""
function which_z(n){
document.getElementById(n).style.zIndex=6
if(last_z==""){
last_z=n
}
else{
document.getElementById(last_z).style.zIndex=""
}
last_z=n
}
// -->
</script>



onmouseup="which_z(this.id)"

jscheuer1
05-11-2007, 05:28 AM
I'm going to assume that your code is working even though I think this last bit should be:


else{
document.getElementById(last_z).style.zIndex=""
last_z=""
}
}

Can't be certain though. OK, if it works, you just need to pass the id of the table or whatever object as a literal string. Let's say the table has an id of 'tbl1':


<table id="tbl1"><tr><td> . . .

Your event would be:


onmouseup="which_z('tbl1')"