...

View Full Version : Open/Close extra information on TD onclick



topdown.me
07-01-2011, 11:18 AM
Hello. I'm trying to open extra information if a user clicks on a TD, and close it if he click on it again. How I can do this? All I learned to do is to show it, but I can't find something that hide it if I click on the same place.

Thanks for help.

__________________
הורדות (http://www.topdown.me)

bullant
07-01-2011, 11:19 AM
That's fairly straight forward to do. Post the code you have so far and we can try to help you get it working.

topdown.me
07-01-2011, 02:43 PM
That's fairly straight forward to do. Post the code you have so far and we can try to help you get it working.

function showdiv(luahid) {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow' +id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.display = 'block';
}
else { // IE 4
document.all.hideshow.style.display = 'block';
}
}
}

I have just a div with ID, that refers to the show extra information function.
I want when the extra informations open, to click on this div again and it will be closed.

devnull69
07-01-2011, 02:58 PM
Wow this is ancient code

Try this instead


function showDiv(id) {
var myElement = document.getElementById('hideshow' + id);
if(myElement.style.display=='block') {
myElement.style.display = 'none';
} else {
myElement.style.display = 'block';
}
}

bullant
07-02-2011, 01:08 AM
I have just a div with ID, that refers to the show extra information function.
I want when the extra informations open, to click on this div again and it will be closed.

I would do something along these lines:




function showHide(id) {
var elemO = document.getElementById('hideshow' + id);
elemO.style.display = ((elemO.style.display == 'block')? 'none' : 'block');
}

topdown.me
07-02-2011, 12:10 PM
Love you ♥



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum