Thread: Javascript Help
View Single Post
Old 12-01-2007, 03:25 PM   #2 (permalink)
Costin Trifan
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 2,953
iTrader: 0 / 0%
Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
Firstly, welcome to v7n, mrjokers!

Now, to answer your question:
1. you need to delete one line from your code (the bolded comented one):
Code:
var el = document.getElementById(element); el.style.left = cur.offsetLeft+"px"; el.style.top = cur.offsetTop+cur.offsetHeight+"px"; //el.style.display = "block";
2. add this lines of code:
Code:
if ( el.style.display == 'none' ) { el.style.display = 'block'; } else { el.style.display = 'none'; }
3. finally, your code should look like this:
Code:
function show(cur,element) { var el = document.getElementById(element); el.style.left = cur.offsetLeft+"px"; el.style.top = cur.offsetTop+cur.offsetHeight+"px"; document.onclick = function(e) { var obj = document.all ? event.srcElement : e.target; if (obj != el && obj != cur) { el.style.display = "none"; } } if ( el.style.display == 'none' ) { el.style.display = 'block'; } else { el.style.display = 'none'; } }
__________________
JUNE - JavaScript Framework

Last edited by Costin Trifan : 12-01-2007 at 03:30 PM.
Costin Trifan is offline   Reply With Quote