onclick - z.index
- Started
- Last post
- 15 Responses
- wwfc
Morning!
I am trying to set some code in DW on multiple layers and the aim is that when a layer is clicked on it jumps to the top level. The multiple layers all have predefined z-index levels from 1 to 35. So I am trying to add some code that makes the layer jump to the top z - this is what I have thus far...
onmousedown="MM_changeProp('idna...
This works - but only for one click - once clicked the layer will jump to the top level - but then if I click on another layer that jumps above it - but if I click an already clicked layer it stays on the same z-index level?
I thought that +555 means that the layer will jump by 555 levels? is that right? or did I just have a vivid dream? what is the correct way of telling a layer to go to the top z-index level when it is clicked on?
...anyone know?
...please?
- wwfc0
http://pastebin.com/m59bf9801
sorry - the code didn't show!idname - is a reference to the layer id - they are all different id's
- neverblink0
+555 doesn't work.
you need to do something like this to actually add the 555:var element = document.getElementByID(id);
var new_z = parseInt( element.style.zindex ) + 555;
element.style.zindex = new_z;
- wwfc0
thanks neverblink - does that go in the onmousedown action?
- wwfc0
...or do I add it somewhere else?
- wwfc0
would this js be the place to add the onclick/startdrag go to top z level command?
http://pastebin.com/m60d374ab
- neverblink0
I'm sorry, but maybe it's better to learn some basics before trying to do this.
- heavyt0
you actually should be able to pass in a different value where you have +555. I posted it to your pastebin.
The concept is that you pass in the current zIndex +555 each time
- wwfc0
...thanks heavyt - could you give me the pastbin url for it?
**agreed neverblink - but having to do this on the fly as it were!
- wwfc0
....ah! bumma! no still doesn't seem to do it! :-(
I would have thought it would make it happen! Any idea what else might do the trick?
- 7point340
how many layers do you have?
put a for statement in the code that moves them all down one index first. and then puts the new one on top. its a simple bit a of coding, but you have to understand "for" and "if then" logic
- 7point340
name all layers sub1, sub2, etc.
for statement something like:
for (i=1; i<7; i++) {
var current = 'sub' + 1;
var z = document. getElementById(current).style.z...
z = z - 1;
}then set the new one to the highest z-index you want to set, ie. 55
- heavyt0
wwfc - check that link again.
I streamlined all the code for you. I just posted the complete html and js to do this thing without all the MM_ bullshizz.
- wwfc0
...great stuff! - thanks for this guys - much appreciated - have a good weekend ;-)
- wwfc0
...nnrghh! - being dumb I know!!!!
how do I get it into this lot???
http://pastebin.com/m39a8536creally would be lowering my stressing levls if someone can show/tell me!
please!